readline-pager 0.7.2 → 0.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # 📄 readline-pager
2
2
 
3
+ <!-- rumdl-disable MD033 -->
3
4
  <p align="center">
4
5
  <img src="https://raw.githubusercontent.com/devmor-j/readline-pager/main/logo.webp" alt="logo" width="349">
5
6
  </p>
@@ -10,9 +11,11 @@
10
11
  </a>
11
12
  <img src="https://img.shields.io/npm/dw/readline-pager" alt="downloads">
12
13
  <img src="https://img.shields.io/github/stars/devmor-j/readline-pager" alt="stars">
14
+ <img src="coverage.svg" alt="coverage">
13
15
  </p>
14
16
 
15
- ⚡ High-performance paginated file reader for Node.js. Process large text files efficiently without loading them into memory.
17
+ ⚡ High-performance paginated file reader for Node.js. Process large text files
18
+ efficiently without loading them into memory.
16
19
 
17
20
  - 📦 Zero dependencies
18
21
  - ⚡ Up to ~3× faster than Node.js `readline`
@@ -20,10 +23,12 @@
20
23
  - 🔁 Async (`for await...of`) and sync (`for...of`) iteration
21
24
  - 📄 Page-based reading with manual control (`next`, `nextSync`)
22
25
  - 🔀 Forward and backward reading support
23
- - 🧪 Fully typed with over 90% test coverage
26
+ - 🧪 Fully typed with high test coverage
24
27
 
25
28
  > **Important:**
26
- > Performance depends heavily on the `chunkSize` option. Tune it for your storage device. A value of **64 KiB** is usually a good starting point. Increasing it may improve throughput until you reach the best value for your hardware.
29
+ > Performance depends heavily on the `chunkSize` option. Tune it for your
30
+ > storage device. A value of **64 KiB** is usually a good starting point.
31
+ > Increasing it may improve throughput until you reach the best value for your hardware.
27
32
 
28
33
  ---
29
34
 
@@ -103,7 +108,9 @@ createNativePager(filepath, {
103
108
  - `output` — Controls the page data type.
104
109
 
105
110
  > **Note:**
106
- > `createNativePager` requires x86 AVX2 or ARM NEON CPU instruction set extensions and will throw if they are not available. It also does **not** support multi-character delimiters because it uses fast SIMD-based scanning.
111
+ > `createNativePager` requires x86 AVX2 or ARM NEON CPU instruction set extensions
112
+ > and will throw if they are not available. It also does **not** support
113
+ > multi-character delimiters because it uses fast SIMD-based scanning.
107
114
 
108
115
  ---
109
116
 
@@ -118,7 +125,8 @@ Returns `null` when the end of the file is reached.
118
125
  Empty lines are preserved.
119
126
 
120
127
  > **Note:**
121
- > Unlike Node.js `readline`, which may skip empty files or leading empty lines, `readline-pager` always returns all lines.
128
+ > Unlike Node.js `readline`, which may skip empty files or leading empty lines,
129
+ > `readline-pager` always returns all lines.
122
130
  >
123
131
  > - A completely empty file (`0` bytes) produces `[""]` on the first read.
124
132
  > - A file containing multiple empty lines returns each line as an empty string.
@@ -149,8 +157,6 @@ node test/benchmark.ts --lines=20000 --page-size=500 --backward
149
157
  > Test setup: generated text files (UUID lines), NVMe SSD, Node.js runtime.
150
158
  > Results are averaged across multiple runs. Actual performance depends on hardware.
151
159
 
152
- ---
153
-
154
160
  ### ⚡ Throughput (MB/s)
155
161
 
156
162
  | Method | 1M lines (35 MB) | 10M lines (353 MB) | 100M lines (3.5 GB) | 1B lines (35.3 GB) |
package/dist/main.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as Output, c as PagerOptions, i as NativeReaderOptions, l as ReaderOptions, n as AsyncFunction, o as PageOutput, r as NativeAddon, s as Pager, t as createNativePager, u as ResolvePageOutput } from "./native-7x1Vhdaw.cjs";
1
+ import { i as PagerOptions, n as Output, r as Pager, t as createNativePager } from "./native-7FzZtBp1.cjs";
2
2
 
3
3
  //#region src/main.d.ts
4
4
  declare function createPager<T extends Output>(filepath: string, options: PagerOptions & {
@@ -6,4 +6,4 @@ declare function createPager<T extends Output>(filepath: string, options: PagerO
6
6
  }): Pager<T>;
7
7
  declare function createPager(filepath: string, options?: PagerOptions): Pager<"string">;
8
8
  //#endregion
9
- export { AsyncFunction, NativeAddon, NativeReaderOptions, Output, PageOutput, Pager, PagerOptions, ReaderOptions, ResolvePageOutput, createNativePager, createPager, createPager as default };
9
+ export { type Pager, type PagerOptions, createNativePager, createPager, createPager as default };
package/dist/main.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as Output, c as PagerOptions, i as NativeReaderOptions, l as ReaderOptions, n as AsyncFunction, o as PageOutput, r as NativeAddon, s as Pager, t as createNativePager, u as ResolvePageOutput } from "./native-D6SBIgoE.mjs";
1
+ import { i as PagerOptions, n as Output, r as Pager, t as createNativePager } from "./native-B0PXEEYw.mjs";
2
2
 
3
3
  //#region src/main.d.ts
4
4
  declare function createPager<T extends Output>(filepath: string, options: PagerOptions & {
@@ -6,4 +6,4 @@ declare function createPager<T extends Output>(filepath: string, options: PagerO
6
6
  }): Pager<T>;
7
7
  declare function createPager(filepath: string, options?: PagerOptions): Pager<"string">;
8
8
  //#endregion
9
- export { AsyncFunction, NativeAddon, NativeReaderOptions, Output, PageOutput, Pager, PagerOptions, ReaderOptions, ResolvePageOutput, createNativePager, createPager, createPager as default };
9
+ export { type Pager, type PagerOptions, createNativePager, createPager, createPager as default };
@@ -1,7 +1,5 @@
1
1
  //#region src/types.d.ts
2
- type AsyncFunction = () => Promise<void>;
3
2
  type Output = "string" | "buffer";
4
- type PageOutput = string[] | Buffer;
5
3
  type ResolvePageOutput<T extends Output> = T extends "buffer" ? Buffer : string[];
6
4
  interface ReaderOptions {
7
5
  chunkSize: number;
@@ -19,14 +17,6 @@ interface NativeReaderOptions {
19
17
  type PagerOptions = Partial<ReaderOptions> & {
20
18
  backward?: boolean;
21
19
  };
22
- type AddonFD = object | null;
23
- type AddonData = Buffer | null;
24
- interface NativeAddon {
25
- open: (filepath: string, pageSize: number, delimiter: string, backward: boolean) => AddonFD;
26
- next: (fd: AddonFD) => Promise<AddonData>;
27
- nextSync: (fd: AddonFD) => AddonData;
28
- close: (fd: AddonFD) => Promise<void>;
29
- }
30
20
  interface Pager<T extends Output = "string"> {
31
21
  next(): Promise<ResolvePageOutput<T> | null>;
32
22
  nextSync(): ResolvePageOutput<T> | null;
@@ -41,4 +31,4 @@ declare function createNativePager<T extends Output>(filepath: string, options:
41
31
  }): Pager<T>;
42
32
  declare function createNativePager(filepath: string, options?: Partial<NativeReaderOptions>): Pager<"string">;
43
33
  //#endregion
44
- export { Output as a, PagerOptions as c, NativeReaderOptions as i, ReaderOptions as l, AsyncFunction as n, PageOutput as o, NativeAddon as r, Pager as s, createNativePager as t, ResolvePageOutput as u };
34
+ export { PagerOptions as i, Output as n, Pager as r, createNativePager as t };
@@ -1,7 +1,5 @@
1
1
  //#region src/types.d.ts
2
- type AsyncFunction = () => Promise<void>;
3
2
  type Output = "string" | "buffer";
4
- type PageOutput = string[] | Buffer;
5
3
  type ResolvePageOutput<T extends Output> = T extends "buffer" ? Buffer : string[];
6
4
  interface ReaderOptions {
7
5
  chunkSize: number;
@@ -19,14 +17,6 @@ interface NativeReaderOptions {
19
17
  type PagerOptions = Partial<ReaderOptions> & {
20
18
  backward?: boolean;
21
19
  };
22
- type AddonFD = object | null;
23
- type AddonData = Buffer | null;
24
- interface NativeAddon {
25
- open: (filepath: string, pageSize: number, delimiter: string, backward: boolean) => AddonFD;
26
- next: (fd: AddonFD) => Promise<AddonData>;
27
- nextSync: (fd: AddonFD) => AddonData;
28
- close: (fd: AddonFD) => Promise<void>;
29
- }
30
20
  interface Pager<T extends Output = "string"> {
31
21
  next(): Promise<ResolvePageOutput<T> | null>;
32
22
  nextSync(): ResolvePageOutput<T> | null;
@@ -41,4 +31,4 @@ declare function createNativePager<T extends Output>(filepath: string, options:
41
31
  }): Pager<T>;
42
32
  declare function createNativePager(filepath: string, options?: Partial<NativeReaderOptions>): Pager<"string">;
43
33
  //#endregion
44
- export { Output as a, PagerOptions as c, NativeReaderOptions as i, ReaderOptions as l, AsyncFunction as n, PageOutput as o, NativeAddon as r, Pager as s, createNativePager as t, ResolvePageOutput as u };
34
+ export { PagerOptions as i, Output as n, Pager as r, createNativePager as t };
package/dist/native.d.cts CHANGED
@@ -1,2 +1,2 @@
1
- import { t as createNativePager } from "./native-7x1Vhdaw.cjs";
1
+ import { t as createNativePager } from "./native-7FzZtBp1.cjs";
2
2
  export { createNativePager };
package/dist/native.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { t as createNativePager } from "./native-D6SBIgoE.mjs";
1
+ import { t as createNativePager } from "./native-B0PXEEYw.mjs";
2
2
  export { createNativePager };
package/package.json CHANGED
@@ -1,32 +1,35 @@
1
1
  {
2
2
  "name": "readline-pager",
3
- "version": "0.7.2",
3
+ "version": "0.7.3",
4
4
  "scripts": {
5
5
  "build:js": "tsdown",
6
6
  "build:native": "node-gyp rebuild",
7
7
  "build": "npm run build:native && npm run build:js",
8
8
  "pretest": "npm run build",
9
- "test": "PAGER_TEST_CLEANUPS=1 node --test --experimental-test-coverage test/**/*.test.ts",
9
+ "test": "PAGER_TEST_CLEANUPS=1 c8 --reporter=lcov --reporter=text node --test test/**/*.test.ts",
10
+ "test:coverage": "npx lcov-badge2 coverage/lcov.info -o coverage.svg",
10
11
  "prepublishOnly": "npm run build && npm run test",
11
12
  "benchmark:node": "node test/benchmark.ts",
12
13
  "benchmark:deno": "deno --allow-write --allow-read --allow-env test/benchmark.ts",
13
14
  "benchmark:bun": "bun test/benchmark.ts"
14
15
  },
15
16
  "devDependencies": {
16
- "@types/bun": "~1.3.12",
17
+ "@types/bun": "~1.3.13",
17
18
  "@types/deno": "~2.5.0",
18
- "@types/node": "~25.6.0",
19
- "node-gyp": "~12.2.0",
20
- "prettier": "~3.8.2",
19
+ "@types/node": "~25.6.2",
20
+ "c8": "~11.0.0",
21
+ "lcov-badge2": "~1.1.4",
22
+ "node-gyp": "~12.3.0",
23
+ "prettier": "~3.8.3",
21
24
  "prettier-plugin-organize-imports": "~4.3.0",
22
- "tsdown": "~0.21.7",
23
- "typescript": "~6.0.2"
25
+ "tsdown": "~0.22.0",
26
+ "typescript": "~6.0.3"
24
27
  },
25
28
  "optionalDependencies": {
26
- "@devmor-j/readline-pager-linux-arm64": "0.7.2",
27
- "@devmor-j/readline-pager-linux-musl-arm64": "0.7.2",
28
- "@devmor-j/readline-pager-linux-musl-x64": "0.7.2",
29
- "@devmor-j/readline-pager-linux-x64": "0.7.2"
29
+ "@devmor-j/readline-pager-linux-arm64": "0.7.3",
30
+ "@devmor-j/readline-pager-linux-musl-arm64": "0.7.3",
31
+ "@devmor-j/readline-pager-linux-musl-x64": "0.7.3",
32
+ "@devmor-j/readline-pager-linux-x64": "0.7.3"
30
33
  },
31
34
  "gypfile": false,
32
35
  "type": "module",