Thanks for your interest in contributing.
- Minimum supported Node.js: >= 18.12
- Recommended dev environment: Node.js v25.x
- TypeScript 6.x
Install dependencies and run tests:
npm i
npm testTests run using the built-in Node test runner with coverage enabled.
src/main.ts— pager factorysrc/reader/— readers engine for forward and backwardsrc/native.ts— native pager factorysrc/native/pager.native.cc— native reader engine implemented in C++ (forward and backward)test/— test files and benchmark tools with some utils only for tests
pageSizecontrols how many lines are returned per page.chunkSizestrongly affects performance and should be tuned per environment.prefetchcontrols internal buffering of pages.- Native mode (
createNativePager) supports only single-character delimiters and a limited subset of options. - The async iterator (
for await...of) and manual iteration (next()) are both supported; manual iteration may provide more control in some cases.
This N-API module relies on C++23 features to optimize high-throughput file reading.
- I/O & Memory: Uses
mmapandmadvisefor zero-copy forward reads. Backward reads must allocate new memory to aggregate reversed segments. - SIMD Vectorization: Runtime CPU detection routes delimiter scanning to AVX2 or NEON paths, processing 64KB blocks against a single-byte delimiter.
- Concurrency: A background
std::jthreadfeeds a bounded, power-of-two ring buffer usingstd::atomicvariables, a mutex, and a condition variable. - Lifecycle Management: Atomic reference counting bridges the N-API async workers, the background thread, and V8 garbage collection finalizers.
Please follow these guidelines:
- Keep changes small and focused
- Ensure all tests pass (keep lines coverage above 90%)
- Add or update tests for any new behavior
- Do not introduce external dependencies
- Maintain the existing API shape unless a change is discussed in an issue first
- Avoid breaking changes without strong justification
- Must work for both ESM and CommonJS users.
When opening an issue, include:
- Node.js version
- Operating system
- Minimal reproduction steps
- Expected vs actual behavior
- Relevant code snippet or file sample
By contributing, you agree that your contributions will be licensed under the MIT License.