spliterator 6.0.1 → 6.2.0
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 +70 -0
- package/out/index.d.ts +26 -23
- package/out/index.d.ts.map +1 -1
- package/out/index.js +26 -23
- package/out/index.js.map +1 -1
- package/out/lib/AsyncSpliterator.d.ts.map +1 -1
- package/out/lib/AsyncSpliterator.js +28 -0
- package/out/lib/AsyncSpliterator.js.map +1 -1
- package/out/lib/CSVSpliterator.d.ts +8 -18
- package/out/lib/CSVSpliterator.d.ts.map +1 -1
- package/out/lib/CSVSpliterator.js +4 -47
- package/out/lib/CSVSpliterator.js.map +1 -1
- package/out/lib/CharacterSequence.d.ts +16 -1
- package/out/lib/CharacterSequence.d.ts.map +1 -1
- package/out/lib/CharacterSequence.js +37 -0
- package/out/lib/CharacterSequence.js.map +1 -1
- package/out/lib/XLSXSpliterator.d.ts +143 -0
- package/out/lib/XLSXSpliterator.d.ts.map +1 -0
- package/out/lib/XLSXSpliterator.js +161 -0
- package/out/lib/XLSXSpliterator.js.map +1 -0
- package/out/lib/core/AsyncSpliterator.d.ts +227 -0
- package/out/lib/core/AsyncSpliterator.d.ts.map +1 -0
- package/out/lib/core/AsyncSpliterator.js +510 -0
- package/out/lib/core/AsyncSpliterator.js.map +1 -0
- package/out/lib/core/BufferController.d.ts +77 -0
- package/out/lib/core/BufferController.d.ts.map +1 -0
- package/out/lib/core/BufferController.js +118 -0
- package/out/lib/core/BufferController.js.map +1 -0
- package/out/lib/core/CharacterSequence.d.ts +72 -0
- package/out/lib/core/CharacterSequence.d.ts.map +1 -0
- package/out/lib/core/CharacterSequence.js +347 -0
- package/out/lib/core/CharacterSequence.js.map +1 -0
- package/out/lib/core/CompositeDataView.d.ts +111 -0
- package/out/lib/core/CompositeDataView.d.ts.map +1 -0
- package/out/lib/core/CompositeDataView.js +241 -0
- package/out/lib/core/CompositeDataView.js.map +1 -0
- package/out/lib/core/IndexQueue.d.ts +48 -0
- package/out/lib/core/IndexQueue.d.ts.map +1 -0
- package/out/lib/core/IndexQueue.js +111 -0
- package/out/lib/core/IndexQueue.js.map +1 -0
- package/out/lib/core/SlidingWindow.d.ts +47 -0
- package/out/lib/core/SlidingWindow.d.ts.map +1 -0
- package/out/lib/core/SlidingWindow.js +63 -0
- package/out/lib/core/SlidingWindow.js.map +1 -0
- package/out/lib/core/Spliterator.d.ts +96 -0
- package/out/lib/core/Spliterator.d.ts.map +1 -0
- package/out/lib/core/Spliterator.js +330 -0
- package/out/lib/core/Spliterator.js.map +1 -0
- package/out/lib/core/wasm_base64.d.ts +19 -0
- package/out/lib/core/wasm_base64.d.ts.map +1 -0
- package/out/lib/core/wasm_base64.js +19 -0
- package/out/lib/core/wasm_base64.js.map +1 -0
- package/out/lib/core/wasm_module.d.ts +57 -0
- package/out/lib/core/wasm_module.d.ts.map +1 -0
- package/out/lib/core/wasm_module.js +34 -0
- package/out/lib/core/wasm_module.js.map +1 -0
- package/out/lib/formats/CSVSpliterator.d.ts +131 -0
- package/out/lib/formats/CSVSpliterator.d.ts.map +1 -0
- package/out/lib/formats/CSVSpliterator.js +172 -0
- package/out/lib/formats/CSVSpliterator.js.map +1 -0
- package/out/lib/formats/JSONSpliterator.d.ts +44 -0
- package/out/lib/formats/JSONSpliterator.d.ts.map +1 -0
- package/out/lib/formats/JSONSpliterator.js +77 -0
- package/out/lib/formats/JSONSpliterator.js.map +1 -0
- package/out/lib/formats/PSVSpliterator.d.ts +21 -0
- package/out/lib/formats/PSVSpliterator.d.ts.map +1 -0
- package/out/lib/formats/PSVSpliterator.js +22 -0
- package/out/lib/formats/PSVSpliterator.js.map +1 -0
- package/out/lib/formats/TSVSpliterator.d.ts +21 -0
- package/out/lib/formats/TSVSpliterator.d.ts.map +1 -0
- package/out/lib/formats/TSVSpliterator.js +22 -0
- package/out/lib/formats/TSVSpliterator.js.map +1 -0
- package/out/lib/formats/TextSpliterator.d.ts +53 -0
- package/out/lib/formats/TextSpliterator.d.ts.map +1 -0
- package/out/lib/formats/TextSpliterator.js +67 -0
- package/out/lib/formats/TextSpliterator.js.map +1 -0
- package/out/lib/formats/XLSXSpliterator.d.ts +143 -0
- package/out/lib/formats/XLSXSpliterator.d.ts.map +1 -0
- package/out/lib/formats/XLSXSpliterator.js +161 -0
- package/out/lib/formats/XLSXSpliterator.js.map +1 -0
- package/out/lib/formats/casing.d.ts +27 -0
- package/out/lib/formats/casing.d.ts.map +1 -0
- package/out/lib/formats/casing.js +68 -0
- package/out/lib/formats/casing.js.map +1 -0
- package/out/lib/formats/row-emitters.d.ts +35 -0
- package/out/lib/formats/row-emitters.d.ts.map +1 -0
- package/out/lib/formats/row-emitters.js +50 -0
- package/out/lib/formats/row-emitters.js.map +1 -0
- package/out/lib/internal/shared.d.ts +155 -0
- package/out/lib/internal/shared.d.ts.map +1 -0
- package/out/lib/internal/shared.js +41 -0
- package/out/lib/internal/shared.js.map +1 -0
- package/out/lib/internal/utils.d.ts +37 -0
- package/out/lib/internal/utils.d.ts.map +1 -0
- package/out/lib/internal/utils.js +39 -0
- package/out/lib/internal/utils.js.map +1 -0
- package/out/lib/io/adaptive-source.d.ts +39 -0
- package/out/lib/io/adaptive-source.d.ts.map +1 -0
- package/out/lib/io/adaptive-source.js +95 -0
- package/out/lib/io/adaptive-source.js.map +1 -0
- package/out/lib/io/writer.d.ts +45 -0
- package/out/lib/io/writer.d.ts.map +1 -0
- package/out/lib/io/writer.js +57 -0
- package/out/lib/io/writer.js.map +1 -0
- package/out/lib/iterators/AsyncSequence.d.ts +180 -0
- package/out/lib/iterators/AsyncSequence.d.ts.map +1 -0
- package/out/lib/iterators/AsyncSequence.js +432 -0
- package/out/lib/iterators/AsyncSequence.js.map +1 -0
- package/out/lib/iterators/chunks.d.ts +20 -0
- package/out/lib/iterators/chunks.d.ts.map +1 -0
- package/out/lib/iterators/chunks.js +36 -0
- package/out/lib/iterators/chunks.js.map +1 -0
- package/out/lib/iterators/pivot.d.ts +30 -0
- package/out/lib/iterators/pivot.d.ts.map +1 -0
- package/out/lib/iterators/pivot.js +47 -0
- package/out/lib/iterators/pivot.js.map +1 -0
- package/out/lib/iterators/zip.d.ts +33 -0
- package/out/lib/iterators/zip.d.ts.map +1 -0
- package/out/lib/iterators/zip.js +59 -0
- package/out/lib/iterators/zip.js.map +1 -0
- package/out/lib/parallel/merge-async-iterators.d.ts +12 -0
- package/out/lib/parallel/merge-async-iterators.d.ts.map +1 -0
- package/out/lib/parallel/merge-async-iterators.js +39 -0
- package/out/lib/parallel/merge-async-iterators.js.map +1 -0
- package/out/lib/parallel/parallel-map-runtime.d.ts +22 -0
- package/out/lib/parallel/parallel-map-runtime.d.ts.map +1 -0
- package/out/lib/parallel/parallel-map-runtime.js +60 -0
- package/out/lib/parallel/parallel-map-runtime.js.map +1 -0
- package/out/lib/parallel/parallel-map-worker-entry.d.ts +11 -0
- package/out/lib/parallel/parallel-map-worker-entry.d.ts.map +1 -0
- package/out/lib/parallel/parallel-map-worker-entry.js +41 -0
- package/out/lib/parallel/parallel-map-worker-entry.js.map +1 -0
- package/out/lib/parallel/parallel-map-workers.d.ts +57 -0
- package/out/lib/parallel/parallel-map-workers.d.ts.map +1 -0
- package/out/lib/parallel/parallel-map-workers.js +82 -0
- package/out/lib/parallel/parallel-map-workers.js.map +1 -0
- package/out/lib/parallel/parallel-map.d.ts +28 -0
- package/out/lib/parallel/parallel-map.d.ts.map +1 -0
- package/out/lib/parallel/parallel-map.js +30 -0
- package/out/lib/parallel/parallel-map.js.map +1 -0
- package/out/lib/parallel/segment-runtime.d.ts +27 -0
- package/out/lib/parallel/segment-runtime.d.ts.map +1 -0
- package/out/lib/parallel/segment-runtime.js +41 -0
- package/out/lib/parallel/segment-runtime.js.map +1 -0
- package/out/lib/parallel/segment-worker-entry.d.ts +10 -0
- package/out/lib/parallel/segment-worker-entry.d.ts.map +1 -0
- package/out/lib/parallel/segment-worker-entry.js +59 -0
- package/out/lib/parallel/segment-worker-entry.js.map +1 -0
- package/out/lib/parallel/segment-workers.d.ts +56 -0
- package/out/lib/parallel/segment-workers.d.ts.map +1 -0
- package/out/lib/parallel/segment-workers.js +110 -0
- package/out/lib/parallel/segment-workers.js.map +1 -0
- package/out/lib/parallel/segments.d.ts +31 -0
- package/out/lib/parallel/segments.d.ts.map +1 -0
- package/out/lib/parallel/segments.js +52 -0
- package/out/lib/parallel/segments.js.map +1 -0
- package/out/lib/row-emitters.d.ts +35 -0
- package/out/lib/row-emitters.d.ts.map +1 -0
- package/out/lib/row-emitters.js +50 -0
- package/out/lib/row-emitters.js.map +1 -0
- package/out/lib/wasm_base64.d.ts +4 -1
- package/out/lib/wasm_base64.d.ts.map +1 -1
- package/out/lib/wasm_base64.js +4 -1
- package/out/lib/wasm_base64.js.map +1 -1
- package/out/lib/wasm_module.d.ts +15 -0
- package/out/lib/wasm_module.d.ts.map +1 -1
- package/out/lib/wasm_module.js +2 -1
- package/out/lib/wasm_module.js.map +1 -1
- package/out/node/cli/commands/csv.d.ts +113 -0
- package/out/node/cli/commands/csv.d.ts.map +1 -1
- package/out/node/cli/commands/csv.js +34 -36
- package/out/node/cli/commands/csv.js.map +1 -1
- package/out/node/cli/commands/iterate.d.ts +92 -0
- package/out/node/cli/commands/iterate.d.ts.map +1 -1
- package/out/node/cli/commands/iterate.js +26 -28
- package/out/node/cli/commands/iterate.js.map +1 -1
- package/out/node/cli/commands/parallel.d.ts +102 -0
- package/out/node/cli/commands/parallel.d.ts.map +1 -0
- package/out/node/cli/commands/parallel.js +426 -0
- package/out/node/cli/commands/parallel.js.map +1 -0
- package/out/node/cli/index.js +5 -0
- package/out/node/cli/index.js.map +1 -1
- package/out/node/cli/spec.d.ts +51 -0
- package/out/node/cli/spec.d.ts.map +1 -0
- package/out/node/cli/spec.js +78 -0
- package/out/node/cli/spec.js.map +1 -0
- package/out/node/cli/utils.d.ts +36 -18
- package/out/node/cli/utils.d.ts.map +1 -1
- package/out/node/cli/utils.js +48 -39
- package/out/node/cli/utils.js.map +1 -1
- package/out/node/fs/index.d.ts +1 -1
- package/out/node/fs/index.d.ts.map +1 -1
- package/out/node/fs/index.js +1 -1
- package/out/node/fs/index.js.map +1 -1
- package/package.json +18 -8
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license MIT
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
import { AsyncSpliterator, type AsyncSpliteratorInit, type SpliteratorInit } from "./AsyncSpliterator.js";
|
|
7
|
+
import { type CharacterSequenceInput } from "./CharacterSequence.js";
|
|
8
|
+
import { type AsyncChunkIterator, type AsyncDataResource } from "../internal/shared.js";
|
|
9
|
+
export { AsyncSpliterator };
|
|
10
|
+
export type { AsyncSpliteratorInit, SpliteratorInit };
|
|
11
|
+
/**
|
|
12
|
+
* A byte stream delimiting iterator.
|
|
13
|
+
*/
|
|
14
|
+
export declare class Spliterator<R extends Uint8Array | DataView | ArrayBuffer = Uint8Array> implements IterableIterator<R>, Disposable {
|
|
15
|
+
#private;
|
|
16
|
+
/**
|
|
17
|
+
* Create a spliterator from an asynchronous resource such as a file.
|
|
18
|
+
*
|
|
19
|
+
* This is an alias for `AsyncSpliterator.from`.
|
|
20
|
+
*
|
|
21
|
+
* @param source - The data resource to read from.
|
|
22
|
+
* @param init - The initialization options for the generator.
|
|
23
|
+
* @see {@linkcode AsyncSpliterator} for usage.
|
|
24
|
+
*/
|
|
25
|
+
static fromAsync: typeof AsyncSpliterator.from;
|
|
26
|
+
/**
|
|
27
|
+
* Create a spliterator from an iterable resource such as a **buffer, array, or string**.
|
|
28
|
+
*
|
|
29
|
+
* @param source - The data resource to read from.
|
|
30
|
+
* @param init - The initialization options for the generator.
|
|
31
|
+
*/
|
|
32
|
+
static fromSync<T extends CharacterSequenceInput>(source: T, init?: SpliteratorInit): Spliterator;
|
|
33
|
+
/**
|
|
34
|
+
* Create a spliterator from an iterable resource such as a **buffer or array**.
|
|
35
|
+
*
|
|
36
|
+
* @param source - The data resource to read from.
|
|
37
|
+
* @param init - The initialization options for the generator.
|
|
38
|
+
* @see {@linkcode Spliterator.fromSync} to ensure synchronous operation for string inputs.
|
|
39
|
+
*/
|
|
40
|
+
static from(source: DataView | ArrayBuffer | Buffer | Iterable<number>, init?: SpliteratorInit): Spliterator;
|
|
41
|
+
/**
|
|
42
|
+
* Create a new delimited generator from an **asynchronous byte stream**.
|
|
43
|
+
*
|
|
44
|
+
* @param source - The data resource to read from.
|
|
45
|
+
* @param init - The initialization options for the generator.
|
|
46
|
+
*
|
|
47
|
+
* @returns A new generator instance, yielding byte ranges.
|
|
48
|
+
*/
|
|
49
|
+
static from(source: AsyncChunkIterator, init?: AsyncSpliteratorInit): AsyncSpliterator;
|
|
50
|
+
/**
|
|
51
|
+
* Create a new delimited generator from a resource such as a **file handle or URL**.
|
|
52
|
+
*
|
|
53
|
+
* @param source - The data resource to read from.
|
|
54
|
+
* @param init - The initialization options for the generator.
|
|
55
|
+
*
|
|
56
|
+
* @returns A new generator instance, yielding byte ranges.
|
|
57
|
+
* @see {@linkcode Spliterator.fromSync} to ensure synchronous operation for string inputs.
|
|
58
|
+
*/
|
|
59
|
+
static from(source: AsyncDataResource, init?: AsyncSpliteratorInit): Promise<AsyncSpliterator>;
|
|
60
|
+
/**
|
|
61
|
+
* Create a new delimited generator from a resource such as a **file handle, URL, or byte stream**.
|
|
62
|
+
*
|
|
63
|
+
* @param source - The data resource to read from.
|
|
64
|
+
* @param init - The initialization options for the generator.
|
|
65
|
+
*
|
|
66
|
+
* @returns A new generator instance, yielding byte ranges.
|
|
67
|
+
* @see {@linkcode Spliterator.fromSync} to ensure synchronous operation for string inputs.
|
|
68
|
+
*/
|
|
69
|
+
static from(source: CharacterSequenceInput | AsyncDataResource | AsyncChunkIterator, init?: SpliteratorInit & AsyncSpliteratorInit): Spliterator | AsyncSpliterator | Promise<AsyncSpliterator>;
|
|
70
|
+
/**
|
|
71
|
+
* Create a new delimited generator from a data resource.
|
|
72
|
+
*/
|
|
73
|
+
static toTransformStream(init: SpliteratorInit): TransformStream<Uint8Array, Uint8Array[]>;
|
|
74
|
+
/**
|
|
75
|
+
* Dispose of the spliterator, closing the file handle if necessary.
|
|
76
|
+
*/
|
|
77
|
+
[Symbol.dispose](): void;
|
|
78
|
+
constructor(source: Uint8Array, init?: SpliteratorInit);
|
|
79
|
+
/**
|
|
80
|
+
* Read the next byte range from the source.
|
|
81
|
+
*/
|
|
82
|
+
next(): IteratorResult<R>;
|
|
83
|
+
/**
|
|
84
|
+
* Collect all the byte ranges from the file.
|
|
85
|
+
*
|
|
86
|
+
* @returns An array of encoded byte ranges.
|
|
87
|
+
* @see {@linkcode toDecodedArray} to automatically decode the byte ranges.
|
|
88
|
+
*/
|
|
89
|
+
toArray(): R[];
|
|
90
|
+
/**
|
|
91
|
+
* Collect all the byte ranges from the file as a string.
|
|
92
|
+
*/
|
|
93
|
+
toDecodedArray(decoder?: import("node:util").TextDecoder): string[];
|
|
94
|
+
[Symbol.iterator](): IterableIterator<R>;
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=Spliterator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Spliterator.d.ts","sourceRoot":"","sources":["../../../lib/core/Spliterator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,gBAAgB,EAAE,KAAK,oBAAoB,EAAE,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACzG,OAAO,EAIN,KAAK,sBAAsB,EAC3B,MAAM,wBAAwB,CAAA;AAE/B,OAAO,EAAoB,KAAK,kBAAkB,EAAE,KAAK,iBAAiB,EAAkB,MAAM,uBAAuB,CAAA;AAEzH,OAAO,EAAE,gBAAgB,EAAE,CAAA;AAE3B,YAAY,EAAE,oBAAoB,EAAE,eAAe,EAAE,CAAA;AAErD;;GAEG;AACH,qBAAa,WAAW,CAAC,CAAC,SAAS,UAAU,GAAG,QAAQ,GAAG,WAAW,G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CAAC,EAAE,CAEpB;IAED;;OAEG;IACI,cAAc,CAAC,OAAO,kCAAoB,GAAG,MAAM,EAAE,CAE3D;IAEM,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,gBAAgB,CAAC,CAAC,CAAC,CAE9C;CACD"}
|
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license MIT
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
// oxlint-disable-next-line unicorn/prefer-export-from
|
|
7
|
+
import { AsyncSpliterator } from "./AsyncSpliterator.js";
|
|
8
|
+
import { CharacterSequence, Delimiters, normalizeCharacterInput, } from "./CharacterSequence.js";
|
|
9
|
+
import { IndexQueue } from "./IndexQueue.js";
|
|
10
|
+
import { isFileHandleLike } from "../internal/shared.js";
|
|
11
|
+
export { AsyncSpliterator };
|
|
12
|
+
/**
|
|
13
|
+
* A byte stream delimiting iterator.
|
|
14
|
+
*/
|
|
15
|
+
export class Spliterator {
|
|
16
|
+
//#region Lifecycle
|
|
17
|
+
/**
|
|
18
|
+
* Create a spliterator from an asynchronous resource such as a file.
|
|
19
|
+
*
|
|
20
|
+
* This is an alias for `AsyncSpliterator.from`.
|
|
21
|
+
*
|
|
22
|
+
* @param source - The data resource to read from.
|
|
23
|
+
* @param init - The initialization options for the generator.
|
|
24
|
+
* @see {@linkcode AsyncSpliterator} for usage.
|
|
25
|
+
*/
|
|
26
|
+
static fromAsync = AsyncSpliterator.from;
|
|
27
|
+
/**
|
|
28
|
+
* Create a spliterator from an iterable resource such as a **buffer, array, or string**.
|
|
29
|
+
*
|
|
30
|
+
* @param source - The data resource to read from.
|
|
31
|
+
* @param init - The initialization options for the generator.
|
|
32
|
+
*/
|
|
33
|
+
static fromSync(source, init = {}) {
|
|
34
|
+
return new Spliterator(normalizeCharacterInput(source), init);
|
|
35
|
+
}
|
|
36
|
+
static from(source, init = {}) {
|
|
37
|
+
if (typeof source === "object" && Symbol.asyncIterator in source) {
|
|
38
|
+
return new AsyncSpliterator(source, init);
|
|
39
|
+
}
|
|
40
|
+
if (typeof source === "string" || source instanceof URL || isFileHandleLike(source)) {
|
|
41
|
+
return import("spliterator/node/fs").then(async ({ createChunkIterator }) => {
|
|
42
|
+
let chunkIterator;
|
|
43
|
+
try {
|
|
44
|
+
chunkIterator = await createChunkIterator(source, {
|
|
45
|
+
highWaterMark: init.highWaterMark,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
if (typeof source === "string" || source instanceof URL) {
|
|
50
|
+
const wrapped = new Error("`Spliterator.from` was called with an invalid async data resource. Did you mean to use `Spliterator.fromSync`?");
|
|
51
|
+
wrapped.cause = error;
|
|
52
|
+
throw wrapped;
|
|
53
|
+
}
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
56
|
+
return new AsyncSpliterator(chunkIterator, init);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return new Spliterator(normalizeCharacterInput(source), init);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Create a new delimited generator from a data resource.
|
|
63
|
+
*/
|
|
64
|
+
static toTransformStream(init) {
|
|
65
|
+
return new TransformStream({
|
|
66
|
+
transform(chunk, controller) {
|
|
67
|
+
const spliterator = new Spliterator(chunk, init);
|
|
68
|
+
controller.enqueue(spliterator.toArray());
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Dispose of the spliterator, closing the file handle if necessary.
|
|
74
|
+
*/
|
|
75
|
+
[Symbol.dispose]() {
|
|
76
|
+
this.#indices.clear();
|
|
77
|
+
}
|
|
78
|
+
constructor(source, init = {}) {
|
|
79
|
+
this.#source = source;
|
|
80
|
+
this.#needle = new CharacterSequence(init.delimiter);
|
|
81
|
+
this.#readPosition = init.position ?? 0;
|
|
82
|
+
this.#highWaterMark = Math.max(this.#needle.length * 4, 4096);
|
|
83
|
+
this.#yieldDropCount = Math.max(0, init.drop ?? 0);
|
|
84
|
+
this.#yieldStopCount = Math.max(init.take ?? Infinity, 0) + this.#yieldDropCount;
|
|
85
|
+
this.#yieldByteEstimate = this.#source.byteLength - this.#readPosition;
|
|
86
|
+
this.#skipEmpty = init.skipEmpty ?? true;
|
|
87
|
+
this.#enableQuoteHandling = init.enableQuoteHandling ?? false;
|
|
88
|
+
this.#crlf = init.crlf ?? false;
|
|
89
|
+
this.#debug = init.debug ?? false;
|
|
90
|
+
this.#log = this.#debug ? console.debug.bind(console) : () => void 0;
|
|
91
|
+
}
|
|
92
|
+
//#endregion
|
|
93
|
+
//#region Private Properties
|
|
94
|
+
/**
|
|
95
|
+
* The byte source to read from.
|
|
96
|
+
*/
|
|
97
|
+
#source;
|
|
98
|
+
/**
|
|
99
|
+
* A queue of index tuples marking the start and end of delimiter positions.
|
|
100
|
+
*
|
|
101
|
+
* Note that indices are relative to the buffer, not the file.
|
|
102
|
+
*
|
|
103
|
+
* This means that the start index is always 0, and the end index is the byte length of the buffer.
|
|
104
|
+
*/
|
|
105
|
+
#indices = new IndexQueue();
|
|
106
|
+
/**
|
|
107
|
+
* The byte sequence to search for, i.e. an encoded delimiter.
|
|
108
|
+
*/
|
|
109
|
+
#needle;
|
|
110
|
+
/**
|
|
111
|
+
* The byte sequence for a double quote.
|
|
112
|
+
*/
|
|
113
|
+
#doubleQuoteSequence = new CharacterSequence('"');
|
|
114
|
+
#enableQuoteHandling;
|
|
115
|
+
/**
|
|
116
|
+
* Whether to trim a carriage return immediately preceding each delimiter match.
|
|
117
|
+
*/
|
|
118
|
+
#crlf;
|
|
119
|
+
/**
|
|
120
|
+
* How many yields to skip.
|
|
121
|
+
*/
|
|
122
|
+
#yieldDropCount;
|
|
123
|
+
/**
|
|
124
|
+
* How many yields to allow before stopping.
|
|
125
|
+
*/
|
|
126
|
+
#yieldStopCount;
|
|
127
|
+
/**
|
|
128
|
+
* The total number of bytes we expect to yield.
|
|
129
|
+
*
|
|
130
|
+
* We use this to ensure that we don't miss any data as we read through the buffer.
|
|
131
|
+
*/
|
|
132
|
+
#yieldByteEstimate;
|
|
133
|
+
/**
|
|
134
|
+
* Whether to skip empty yields.
|
|
135
|
+
*/
|
|
136
|
+
#skipEmpty;
|
|
137
|
+
/**
|
|
138
|
+
* The high water mark for the buffer.
|
|
139
|
+
*
|
|
140
|
+
* This defines the total size of indices to keep in memory.
|
|
141
|
+
*/
|
|
142
|
+
#highWaterMark;
|
|
143
|
+
/**
|
|
144
|
+
* The total number of bytes we've yielded.
|
|
145
|
+
*/
|
|
146
|
+
#yieldedByteLength = 0;
|
|
147
|
+
/**
|
|
148
|
+
* The total number of yields.
|
|
149
|
+
*/
|
|
150
|
+
#yieldCount = 0;
|
|
151
|
+
/**
|
|
152
|
+
* The current byte index to perform read operations from.
|
|
153
|
+
*/
|
|
154
|
+
#readPosition;
|
|
155
|
+
/**
|
|
156
|
+
* The previous byte range seen while draining the buffer.
|
|
157
|
+
*/
|
|
158
|
+
#previousByteRange;
|
|
159
|
+
/**
|
|
160
|
+
* Whether to output debug information.
|
|
161
|
+
*/
|
|
162
|
+
#debug;
|
|
163
|
+
/**
|
|
164
|
+
* Whether the iterator is done.
|
|
165
|
+
*/
|
|
166
|
+
#done = false;
|
|
167
|
+
//#endregion
|
|
168
|
+
//#region Private Methods
|
|
169
|
+
#log;
|
|
170
|
+
#finalize() {
|
|
171
|
+
if (this.#debug) {
|
|
172
|
+
/**
|
|
173
|
+
* The total number of bytes we expect to be omitted from the buffer. This is derived from the number of of yields
|
|
174
|
+
* and the length of the delimiter.
|
|
175
|
+
*/
|
|
176
|
+
const expectedYieldedDelimitedBytes = (this.#yieldCount - 1) * this.#needle.length;
|
|
177
|
+
const omittedBytes = this.#yieldByteEstimate - (this.#yieldedByteLength + expectedYieldedDelimitedBytes);
|
|
178
|
+
this.#log({
|
|
179
|
+
totalByteSize: this.#source.byteLength,
|
|
180
|
+
readPosition: this.#readPosition,
|
|
181
|
+
yieldByteEstimate: this.#yieldByteEstimate,
|
|
182
|
+
yieldedByteLength: this.#yieldedByteLength,
|
|
183
|
+
yieldCount: this.#yieldCount,
|
|
184
|
+
expectedYieldedDelimitedBytes,
|
|
185
|
+
omittedBytes,
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
return {
|
|
189
|
+
done: true,
|
|
190
|
+
value: undefined,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
#drain() {
|
|
194
|
+
const sourceByteLength = this.#source.byteLength;
|
|
195
|
+
this.#log("Reached end of file. Preparing to finalize.");
|
|
196
|
+
// There's a few special cases we could get this far and not have drained the buffer.
|
|
197
|
+
const lastByteRange = this.#previousByteRange;
|
|
198
|
+
if (this.#readPosition < sourceByteLength) {
|
|
199
|
+
this.#indices.enqueue([this.#readPosition, sourceByteLength]);
|
|
200
|
+
}
|
|
201
|
+
else if (this.#yieldCount === 0 && lastByteRange === undefined) {
|
|
202
|
+
// Nothing was ever found or yielded (e.g. an empty source) — emit the whole buffer as
|
|
203
|
+
// a single field. A run of all-empty fields that `skipEmpty` dropped has a defined
|
|
204
|
+
// `lastByteRange`, so it falls through to the trailing-delimiter case instead of
|
|
205
|
+
// resurfacing the entire delimiter run as one (non-empty) row.
|
|
206
|
+
this.#indices.enqueue([0, sourceByteLength]);
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
// Emit an empty field for a trailing delimiter (match String.split). `#fill` always
|
|
210
|
+
// leaves the tail after the last consumed delimiter to this method, in both the plain
|
|
211
|
+
// and quote-aware paths — a source ending exactly on a delimiter has an empty tail.
|
|
212
|
+
const trailingDelimPos = sourceByteLength - this.#needle.length;
|
|
213
|
+
if (trailingDelimPos >= 0 && this.#needle.search(this.#source, trailingDelimPos) !== -1) {
|
|
214
|
+
this.#indices.enqueue([sourceByteLength, sourceByteLength]);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
this.#done = true;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Trim a carriage return immediately preceding a delimiter match, when {@linkcode SpliteratorInit.crlf} is set.
|
|
221
|
+
* Affects only the emitted range's end — `#readPosition` advancement always uses the raw match offset.
|
|
222
|
+
*/
|
|
223
|
+
#trimEnd(start, end) {
|
|
224
|
+
if (this.#crlf && end > start && this.#source[end - 1] === Delimiters.CarriageReturn) {
|
|
225
|
+
return end - 1;
|
|
226
|
+
}
|
|
227
|
+
return end;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Fill the buffer with data and search for delimiters.
|
|
231
|
+
*/
|
|
232
|
+
#fill() {
|
|
233
|
+
const sourceByteLength = this.#source.byteLength;
|
|
234
|
+
if (!this.#enableQuoteHandling) {
|
|
235
|
+
while (this.#readPosition < sourceByteLength && this.#indices.byteLength < this.#highWaterMark) {
|
|
236
|
+
const delimiterIndex = this.#needle.search(this.#source, this.#readPosition);
|
|
237
|
+
if (delimiterIndex === -1)
|
|
238
|
+
return;
|
|
239
|
+
this.#indices.enqueue([this.#readPosition, this.#trimEnd(this.#readPosition, delimiterIndex)]);
|
|
240
|
+
this.#readPosition = delimiterIndex + this.#needle.length;
|
|
241
|
+
}
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
// Quote-aware path: a delimiter inside a double-quoted region does not split, and the
|
|
245
|
+
// emitted slices keep their quotes verbatim — stripping and `""` unescaping belong to the
|
|
246
|
+
// consumer (CSVSpliterator does both). The tail after the last consumed delimiter is left
|
|
247
|
+
// to `#drain`, same as the plain path.
|
|
248
|
+
while (this.#readPosition < sourceByteLength && this.#indices.byteLength < this.#highWaterMark) {
|
|
249
|
+
const matches = this.#needle.searchMatches(this.#source, this.#doubleQuoteSequence, this.#readPosition, sourceByteLength);
|
|
250
|
+
if (!matches.length)
|
|
251
|
+
return;
|
|
252
|
+
let sliceStart = this.#readPosition;
|
|
253
|
+
let insideQuotes = false;
|
|
254
|
+
for (const match of matches) {
|
|
255
|
+
if (match.patternId === 1) {
|
|
256
|
+
insideQuotes = !insideQuotes;
|
|
257
|
+
continue;
|
|
258
|
+
}
|
|
259
|
+
// A delimiter inside quotes is part of the slice, so skip it.
|
|
260
|
+
if (insideQuotes)
|
|
261
|
+
continue;
|
|
262
|
+
this.#indices.enqueue([sliceStart, this.#trimEnd(sliceStart, match.offset)]);
|
|
263
|
+
sliceStart = match.offset + this.#needle.length;
|
|
264
|
+
}
|
|
265
|
+
// No delimiter was consumed (e.g. an unclosed quote swallows the rest of the source) —
|
|
266
|
+
// leave the tail to `#drain` rather than rescanning the same matches forever.
|
|
267
|
+
if (sliceStart === this.#readPosition)
|
|
268
|
+
return;
|
|
269
|
+
this.#readPosition = sliceStart;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
//#endregion
|
|
273
|
+
//#region Iterator Methods
|
|
274
|
+
/**
|
|
275
|
+
* Read the next byte range from the source.
|
|
276
|
+
*/
|
|
277
|
+
next() {
|
|
278
|
+
// Loop rather than recurse: a long run of skipped (empty or dropped) ranges would
|
|
279
|
+
// otherwise grow the call stack one frame per skip and overflow.
|
|
280
|
+
while (true) {
|
|
281
|
+
if (this.#done || this.#yieldCount >= this.#yieldStopCount)
|
|
282
|
+
return this.#finalize();
|
|
283
|
+
if (!this.#indices.size) {
|
|
284
|
+
this.#fill();
|
|
285
|
+
}
|
|
286
|
+
if (!this.#indices.size) {
|
|
287
|
+
this.#drain();
|
|
288
|
+
}
|
|
289
|
+
const currentByteRange = this.#indices.dequeue();
|
|
290
|
+
this.#previousByteRange = currentByteRange;
|
|
291
|
+
if (!currentByteRange) {
|
|
292
|
+
this.#done = true;
|
|
293
|
+
return this.#finalize();
|
|
294
|
+
}
|
|
295
|
+
const [start, end] = currentByteRange;
|
|
296
|
+
const slice = this.#source.subarray(start, end);
|
|
297
|
+
if (!slice.length && this.#skipEmpty) {
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
300
|
+
this.#yieldCount++;
|
|
301
|
+
if (this.#yieldCount <= this.#yieldDropCount) {
|
|
302
|
+
continue;
|
|
303
|
+
}
|
|
304
|
+
this.#yieldedByteLength += end - start;
|
|
305
|
+
return {
|
|
306
|
+
value: slice,
|
|
307
|
+
done: false,
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Collect all the byte ranges from the file.
|
|
313
|
+
*
|
|
314
|
+
* @returns An array of encoded byte ranges.
|
|
315
|
+
* @see {@linkcode toDecodedArray} to automatically decode the byte ranges.
|
|
316
|
+
*/
|
|
317
|
+
toArray() {
|
|
318
|
+
return Array.from(this);
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Collect all the byte ranges from the file as a string.
|
|
322
|
+
*/
|
|
323
|
+
toDecodedArray(decoder = new TextDecoder()) {
|
|
324
|
+
return Array.from(this, (bytes) => decoder.decode(bytes));
|
|
325
|
+
}
|
|
326
|
+
[Symbol.iterator]() {
|
|
327
|
+
return this;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
//# sourceMappingURL=Spliterator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Spliterator.js","sourceRoot":"","sources":["../../../lib/core/Spliterator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,sDAAsD;AACtD,OAAO,EAAE,gBAAgB,EAAmD,MAAM,uBAAuB,CAAA;AACzG,OAAO,EACN,iBAAiB,EACjB,UAAU,EACV,uBAAuB,GAEvB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,gBAAgB,EAAmE,MAAM,uBAAuB,CAAA;AAEzH,OAAO,EAAE,gBAAgB,EAAE,CAAA;AAI3B;;GAEG;AACH,MAAM,OAAO,WAAW;IAGvB,mBAAmB;IAEnB;;;;;;;;OAQG;IACH,MAAM,CAAC,SAAS,GAAG,gBAAgB,CAAC,IAAI,CAAA;IAExC;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,CAAmC,MAAS,E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AI,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;IAC1D,CAAC;IAEM,CAAC,MAAM,CAAC,QAAQ,CAAC;QACvB,OAAO,IAAI,CAAA;IACZ,CAAC;CACD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license MIT
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
* Base64-encoded WASM module for SIMD-accelerated delimiter scanning.
|
|
6
|
+
* Generated by wasm/build.sh — do not edit by hand.
|
|
7
|
+
* The module exports:
|
|
8
|
+
* - memory: WebAssembly.Memory (1 page = 64KB initial, grows on demand, no fixed maximum)
|
|
9
|
+
* - find_delimiter(haystack_offset, haystack_len, pattern_offset, pattern_len) → i32
|
|
10
|
+
* Returns the byte offset of the first match, or -1.
|
|
11
|
+
* - find_all_delimiters(haystack_offset, haystack_len, pattern_offset, pattern_len,
|
|
12
|
+
* results_offset, max_results) → usize
|
|
13
|
+
* Writes (start, end) i32 pairs to results_offset, returns count.
|
|
14
|
+
* - scan_delimited_ranges(haystack_offset, haystack_len, scan_start, pending_slice_start,
|
|
15
|
+
* delimiter, quote, inside_quotes, results_offset, max_ranges) → usize
|
|
16
|
+
* Writes resumable scan state followed by bounded (start, end) i32 pairs.
|
|
17
|
+
*/
|
|
18
|
+
export declare const WASM_BASE64 = "AGFzbQEAAAABKwRgBH9/f38Bf2AGf39/f39/AX9gB39/f39/f38Bf2AJf39/f39/f39/AX8DBgUAAQIAAwUDAQABB1wFBm1lbW9yeQIAE2ZpbmRfYWxsX2RlbGltaXRlcnMAARBmaW5kX2FsbF9tYXRjaGVzAAIOZmluZF9kZWxpbWl0ZXIAAxVzY2FuX2RlbGltaXRlZF9yYW5nZXMABArfDwXEAgINfwF7IAItAAAhCyABIANBAWsiDWsiBEEAIAEgBE8bIglBEE8EQCAL/Q8hESAAI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BQQEhBgwCCyAGQQFzIQYMAQsgCyAMaiEGIAggCUsEQCAHIAlBA3RqIgxBEGogBjYCACAMQQxqIAo2AgAgBkEBaiEKIAlBAWohCUEAIQYMAQsgByAKNgIEIAcgBjYCAAwFCyADQQFrIANxIgMNAAsLIAJBEGoiAyABTQ0ACwsgASACSwRAIARB/wFxIQMgBUEATiEEA0ACQCADIAAgAmotAAAiC0cEQCAGIAQgCyAFQf8BcUZxcyEGDAELIAZBAXEEQEEBIQYMAQsgCCAJSwRAIAcgCUEDdGoiBkEQaiACNgIAIAZBDGogCjYCACACQQFqIQogCUEBaiEJQQAhBgwBCyAHIAo2AgQgByACNgIADAMLIAEgAkEBaiICRw0ACwsgByAKNgIEIAcgATYCACAGQQFxDAELQQALNgIIIAkL";
|
|
19
|
+
//# sourceMappingURL=wasm_base64.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wasm_base64.d.ts","sourceRoot":"","sources":["../../../lib/core/wasm_base64.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,WAAW,61FACm0F,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license MIT
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
* Base64-encoded WASM module for SIMD-accelerated delimiter scanning.
|
|
6
|
+
* Generated by wasm/build.sh — do not edit by hand.
|
|
7
|
+
* The module exports:
|
|
8
|
+
* - memory: WebAssembly.Memory (1 page = 64KB initial, grows on demand, no fixed maximum)
|
|
9
|
+
* - find_delimiter(haystack_offset, haystack_len, pattern_offset, pattern_len) → i32
|
|
10
|
+
* Returns the byte offset of the first match, or -1.
|
|
11
|
+
* - find_all_delimiters(haystack_offset, haystack_len, pattern_offset, pattern_len,
|
|
12
|
+
* results_offset, max_results) → usize
|
|
13
|
+
* Writes (start, end) i32 pairs to results_offset, returns count.
|
|
14
|
+
* - scan_delimited_ranges(haystack_offset, haystack_len, scan_start, pending_slice_start,
|
|
15
|
+
* delimiter, quote, inside_quotes, results_offset, max_ranges) → usize
|
|
16
|
+
* Writes resumable scan state followed by bounded (start, end) i32 pairs.
|
|
17
|
+
*/
|
|
18
|
+
export const WASM_BASE64 = "AGFzbQEAAAABKwRgBH9/f38Bf2AGf39/f39/AX9gB39/f39/f38Bf2AJf39/f39/f39/AX8DBgUAAQIAAwUDAQABB1wFBm1lbW9yeQIAE2ZpbmRfYWxsX2RlbGltaXRlcnMAARBmaW5kX2FsbF9tYXRjaGVzAAIOZmluZF9kZWxpbWl0ZXIAAxVzY2FuX2RlbGltaXRlZF9yYW5nZXMABArfDwXEAgINfwF7IAItAAAhCyABIANBAWsiDWsiBEEAIAEgBE8bIglBEE8EQCAL/Q8hESAAIQpBECEEA0AgBSEMIAQhBSAAIAxq/QAAACAR/SP9ZCIGBEADQCABIAZoIgQgDGoiDiADak8EQCAEIApqIQcgAyEEIAIhCANAIARFBEAgDg8LIARBAWshBCAILQAAIActAAAgCEEBaiEIIAdBAWohB0YNAAsLIAZBAWsgBnEiBg0ACwsgCkEQaiEKIAVBEGoiBCAJTQ0ACwsgBSAJSQRAIAJBAWohASAAIAVqQQFqIQYDQCANIQQgASEHIAYhCAJAIAAgBWotAAAgC0cNAANAIAQEQCAEQQFrIQQgBy0AACAILQAAIAdBAWohByAIQQFqIQhGDQEMAgsLIAUPCyAGQQFqIQYgBUEBaiIFIAlJDQALC0F/C5MCAgl/AXsCQCAFRSABRSADRXJyRQRAIAEgA0kNASADQQFHIQ0DQCAAIAlqIQogASAJayELAn8gDUUEQCACLQAAIg79DyEPQQAhBgJAA0AgBkEQaiIHIAtLDQEgBiAKaiAHIQb9AAAAIA/9I/1kIgdFDQALIAdoIAZBEGtqDAILA0AgBiALTw0FIAYgCmogBkEBaiEGLQAAIA5HDQALIAZBAWsMAQsgCiALIAIgAxAACyIGQQBIDQIgBCAIQQN0aiIMIAYgCWoiBzYC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FqIgkgAU8NASAGIAhLDQALCyAIC5IBAgN/AXtBfyEFAkAgA0EBayABTw0AIANBAUYEQCACLQAAIgL9DyEHQQAhAwNAIAEgA0EQaiIESQRAA0AgASADTQ0EIAAgA2ogA0EBaiEDLQAAIAJHDQALIANBAWsPCyAAIANqIAQhA/0AAAAgB/0j/WQiBEUNAAsgBGggA0EQa2oPCyAAIAEgAiADEAAhBQsgBQvoAwIIfwN7IAEgAyABIANJGyEKIAZBAEchBiAHAn8CQCABIAEgAiABIAJJGyICQRBqIgNPBEAgBf0PIREgBP0PIRIgBUEATiENA0AgAiELIAMhAiAAIAtq/QAAACITIBH9I/1kQQAgDRsiDiATIBL9I/1kIg9yIgMEQANAIANoIQwCQAJAAkACQCAFQQBIDQBBASAMdCIQIA9xDQAgDiAQcQ0BCyAGQQFxRQ0BQQEhBgwCCyAGQQFzIQYMAQsgCyAMaiEGIAggCUsEQCAHIAlBA3RqIgxBEGogBjYCACAMQQxqIAo2AgAgBkEBaiEKIAlBAWohCUEAIQYMAQsgByAKNgIEIAcgBjYCAAwFCyADQQFrIANxIgMNAAsLIAJBEGoiAyABTQ0ACwsgASACSwRAIARB/wFxIQMgBUEATiEEA0ACQCADIAAgAmotAAAiC0cEQCAGIAQgCyAFQf8BcUZxcyEGDAELIAZBAXEEQEEBIQYMAQsgCCAJSwRAIAcgCUEDdGoiBkEQaiACNgIAIAZBDGogCjYCACACQQFqIQogCUEBaiEJQQAhBgwBCyAHIAo2AgQgByACNgIADAMLIAEgAkEBaiICRw0ACwsgByAKNgIEIAcgATYCACAGQQFxDAELQQALNgIIIAkL";
|
|
19
|
+
//# sourceMappingURL=wasm_base64.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wasm_base64.js","sourceRoot":"","sources":["../../../lib/core/wasm_base64.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,WAAW,GACvB,01FAA01F,CAAA"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license MIT
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
export declare function loadWasmModule(): Promise<WasmDelimiterScanner | null>;
|
|
7
|
+
type WasmFindDelimiter = (ho: number, hl: number, po: number, pl: number) => number;
|
|
8
|
+
type WasmFindAllDelimiters = (ho: number, hl: number, po: number, pl: number, ro: number, mr: number) => number;
|
|
9
|
+
type WasmFindAllMatches = (ho: number, hl: number, p1o: number, p1l: number, p2l: number, ro: number, mr: number) => number;
|
|
10
|
+
type WasmScanDelimitedRanges = (ho: number, hl: number, ss: number, pss: number, delimiter: number, quote: number, insideQuotes: number, ro: number, mr: number) => number;
|
|
11
|
+
export interface WasmMemory {
|
|
12
|
+
readonly buffer: ArrayBuffer;
|
|
13
|
+
grow(pages: number): number;
|
|
14
|
+
}
|
|
15
|
+
export interface WasmDelimiterScanner {
|
|
16
|
+
memory: WasmMemory;
|
|
17
|
+
findDelimiter: WasmFindDelimiter;
|
|
18
|
+
findAllDelimiters: WasmFindAllDelimiters;
|
|
19
|
+
findAllMatches: WasmFindAllMatches;
|
|
20
|
+
scanDelimitedRanges: WasmScanDelimitedRanges;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Match result from find_all_matches: [offset, pattern_id].
|
|
24
|
+
*/
|
|
25
|
+
export interface MatchResult {
|
|
26
|
+
/**
|
|
27
|
+
* Byte offset of the match within the haystack.
|
|
28
|
+
*/
|
|
29
|
+
offset: number;
|
|
30
|
+
/**
|
|
31
|
+
* 0 = pattern 1 (delimiter), 1 = pattern 2 (quote).
|
|
32
|
+
*/
|
|
33
|
+
patternId: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Minimum haystack size (bytes) at which the WASM SIMD scanner is used instead of the JS scan, once the module has
|
|
37
|
+
* loaded. Empirically WASM wins well below this — ~8x for single-byte `searchAll` and ~3x for multi-byte `search` at
|
|
38
|
+
* 512 bytes, with sub-µs fixed overhead — so 512 captures typical delimited rows while skipping only the tiny-buffer
|
|
39
|
+
* regime where it doesn't matter.
|
|
40
|
+
*/
|
|
41
|
+
export declare const WASM_THRESHOLD = 512;
|
|
42
|
+
export declare const WASM_MAX_RESULTS = 4096;
|
|
43
|
+
/**
|
|
44
|
+
* State returned by the bounded, resumable range scanner.
|
|
45
|
+
*/
|
|
46
|
+
export interface WasmRangeScanResult {
|
|
47
|
+
/**
|
|
48
|
+
* A shared-memory view of `[start, end]` pairs. Consume it before the next WASM scan.
|
|
49
|
+
*/
|
|
50
|
+
ranges: Int32Array;
|
|
51
|
+
count: number;
|
|
52
|
+
scanCursor: number;
|
|
53
|
+
pendingSliceStart: number;
|
|
54
|
+
insideQuotes: boolean;
|
|
55
|
+
}
|
|
56
|
+
export {};
|
|
57
|
+
//# sourceMappingURL=wasm_module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wasm_module.d.ts","sourceRoot":"","sources":["../../../lib/core/wasm_module.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAiBH,wBAAsB,cAAc,IAAI,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAmB3E;AAED,KAAK,iBAAiB,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,MAAM,CAAA;AAEnF,KAAK,qBAAqB,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,MAAM,CAAA;AAE/G,KAAK,kBAAkB,GAAG,CACzB,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,GA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
import { WASM_BASE64 } from "./wasm_base64.js";
|
|
7
|
+
export async function loadWasmModule() {
|
|
8
|
+
if (!WASM_BASE64)
|
|
9
|
+
return null;
|
|
10
|
+
try {
|
|
11
|
+
const bytes = Uint8Array.from(atob(WASM_BASE64), (c) => c.charCodeAt(0));
|
|
12
|
+
const module = await WebAssembly.compile(bytes);
|
|
13
|
+
const instance = await WebAssembly.instantiate(module, {});
|
|
14
|
+
const e = instance.exports;
|
|
15
|
+
const memory = e.memory;
|
|
16
|
+
const findDelimiter = e.find_delimiter;
|
|
17
|
+
const findAllDelimiters = e.find_all_delimiters;
|
|
18
|
+
const findAllMatches = e.find_all_matches;
|
|
19
|
+
const scanDelimitedRanges = e.scan_delimited_ranges;
|
|
20
|
+
return { memory, findDelimiter, findAllDelimiters, findAllMatches, scanDelimitedRanges };
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Minimum haystack size (bytes) at which the WASM SIMD scanner is used instead of the JS scan, once the module has
|
|
28
|
+
* loaded. Empirically WASM wins well below this — ~8x for single-byte `searchAll` and ~3x for multi-byte `search` at
|
|
29
|
+
* 512 bytes, with sub-µs fixed overhead — so 512 captures typical delimited rows while skipping only the tiny-buffer
|
|
30
|
+
* regime where it doesn't matter.
|
|
31
|
+
*/
|
|
32
|
+
export const WASM_THRESHOLD = 512;
|
|
33
|
+
export const WASM_MAX_RESULTS = 4096;
|
|
34
|
+
//# sourceMappingURL=wasm_module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wasm_module.js","sourceRoot":"","sources":["../../../lib/core/wasm_module.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAe9C,MAAM,CAAC,KAAK,UAAU,cAAc;IACnC,IAAI,CAAC,WAAW;QAAE,OAAO,IAAI,CAAA;IAE7B,IAA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