spliterator 6.1.0 → 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 +18 -0
- package/out/index.d.ts +26 -25
- package/out/index.d.ts.map +1 -1
- package/out/index.js +26 -25
- 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/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/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/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 +6 -6
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license MIT
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* A class to manage a buffer of bytes, growing and shrinking as needed.
|
|
8
|
+
*/
|
|
9
|
+
export class BufferController {
|
|
10
|
+
/**
|
|
11
|
+
* The initial size of the buffer.
|
|
12
|
+
*/
|
|
13
|
+
#initialBufferSize;
|
|
14
|
+
/**
|
|
15
|
+
* The underlying buffer containing the data.
|
|
16
|
+
*
|
|
17
|
+
* This property is mutable for performance reasons. Consumers should treat it as immutable.
|
|
18
|
+
*/
|
|
19
|
+
bytes;
|
|
20
|
+
/**
|
|
21
|
+
* The total number of bytes currently written to the buffer.
|
|
22
|
+
*
|
|
23
|
+
* This property is mutable for performance reasons. Consumers should treat it as immutable.
|
|
24
|
+
*/
|
|
25
|
+
bytesWritten;
|
|
26
|
+
/**
|
|
27
|
+
* The minimum byte length of the buffer.
|
|
28
|
+
*/
|
|
29
|
+
get byteLengthMinimum() {
|
|
30
|
+
return Math.max(this.bytesWritten, this.#initialBufferSize);
|
|
31
|
+
}
|
|
32
|
+
constructor(init) {
|
|
33
|
+
this.#initialBufferSize = init.initialBufferSize;
|
|
34
|
+
this.bytes = new Uint8Array(this.#initialBufferSize);
|
|
35
|
+
this.bytesWritten = 0;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Grow the buffer to the desired byte length, typically double the current byte length.
|
|
39
|
+
*/
|
|
40
|
+
grow(desiredByteLength) {
|
|
41
|
+
desiredByteLength ??= this.bytes.length * 2;
|
|
42
|
+
if (desiredByteLength <= this.bytes.length)
|
|
43
|
+
return;
|
|
44
|
+
// console.debug(`Growing buffer from ${this.bytes.length} to ${desiredByteLength} bytes.`)
|
|
45
|
+
const newBytes = new Uint8Array(desiredByteLength);
|
|
46
|
+
newBytes.set(this.bytes);
|
|
47
|
+
this.bytes = newBytes;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Modify the buffer in place, keeping only the bytes between the start and end indices.
|
|
51
|
+
*
|
|
52
|
+
* This is performed after we're confident that any data preceeding `start` or following `end` is no longer needed.
|
|
53
|
+
*
|
|
54
|
+
* `bytesWritten` is rebased onto the new window so it always reflects the count of valid bytes present after
|
|
55
|
+
* compression. Bytes outside the kept window are dropped from the count even if the underlying allocation is larger.
|
|
56
|
+
*
|
|
57
|
+
* @param start - The starting byte index of which bytes to keep.
|
|
58
|
+
* @param end - The ending byte index of which bytes to keep. Defaults to the current buffer length. Values past the
|
|
59
|
+
* buffer length are clamped.
|
|
60
|
+
*/
|
|
61
|
+
compress(start = 0, end = this.bytes.length) {
|
|
62
|
+
const clampedEnd = Math.min(end, this.bytes.length);
|
|
63
|
+
const validEnd = Math.min(this.bytesWritten, clampedEnd);
|
|
64
|
+
this.bytes = this.bytes.subarray(start, clampedEnd);
|
|
65
|
+
this.bytesWritten = Math.max(0, validEnd - start);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Clear the buffer, zeroing out all bytes.
|
|
69
|
+
*
|
|
70
|
+
* @param begin The starting byte index from which to clear.
|
|
71
|
+
* @param end The ending byte index to clear.
|
|
72
|
+
*/
|
|
73
|
+
clear(begin = 0, end = this.bytesWritten) {
|
|
74
|
+
this.bytes.fill(0, begin, end);
|
|
75
|
+
this.bytesWritten = 0;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Gets a new Uint8Array view of the ArrayBuffer store for this array, referencing the elements at begin, inclusive,
|
|
79
|
+
* up to end, exclusive.
|
|
80
|
+
*
|
|
81
|
+
* @param begin — The index of the beginning of the array.
|
|
82
|
+
* @param end — The index of the end of the array
|
|
83
|
+
* @throws If the start index is greater than the end index.
|
|
84
|
+
* @throws If the end index is greater than the current byte length.
|
|
85
|
+
*/
|
|
86
|
+
subarray(begin = 0, end = this.bytesWritten) {
|
|
87
|
+
if (begin > end) {
|
|
88
|
+
throw new RangeError(`Start index ${begin} is greater than end index ${end}.`);
|
|
89
|
+
}
|
|
90
|
+
if (end > this.bytesWritten) {
|
|
91
|
+
throw new RangeError(`End index ${end} is greater than the current byte length ${this.bytesWritten}.`);
|
|
92
|
+
}
|
|
93
|
+
return this.bytes.subarray(begin, end);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Sets a value or an array of values.
|
|
97
|
+
*
|
|
98
|
+
* Unlike the `TypedArray.set` method, this method will grow the buffer if the offset is greater than the current byte
|
|
99
|
+
* length.
|
|
100
|
+
*
|
|
101
|
+
* @param array — A typed or untyped array of values to set.
|
|
102
|
+
* @param offset — The index in the current array at which the values are to be written.
|
|
103
|
+
*
|
|
104
|
+
* @returns The number of bytes written.
|
|
105
|
+
*/
|
|
106
|
+
set(array, offset = 0) {
|
|
107
|
+
const nextLength = offset + array.length;
|
|
108
|
+
if (nextLength > this.bytes.length) {
|
|
109
|
+
this.grow(nextLength);
|
|
110
|
+
}
|
|
111
|
+
this.bytes.set(array, offset);
|
|
112
|
+
if (nextLength > this.bytesWritten) {
|
|
113
|
+
this.bytesWritten = nextLength;
|
|
114
|
+
}
|
|
115
|
+
return nextLength;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=BufferController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BufferController.js","sourceRoot":"","sources":["../../../lib/core/BufferController.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,OAAO,gBAAgB;IAC5B;;OAEG;IACH,kBAAkB,CAAQ;IAE1B;;;;OAIG;IACH,KAAK,CAAY;IAEjB;;;;OAIG;IACH,YAAY,CAAQ;IAEpB;;OAEG;IACH,IAAW,iBAAiB;QAC3B,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAA;IAC5D,CAAC;IAED,YAAY,IAAmC;QAC9C,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,iBAAiB,CAAA;QAChD,IAAI,CAAC,KAAK,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAA;QACpD,IAAI,CAAC,YAAY,GAAG,CAAC,CAAA;IACtB,CAAC;IAED;;OAEG;IACI,IAAI,CAAC,iBAA0B;QACrC,iBAAiB,KAAK,IA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AAG,GAAG,CAAC,CAAA;QAC/E,CAAC;QAED,IAAI,GAAG,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;YAC7B,MAAM,IAAI,UAAU,CAAC,aAAa,GAAG,4CAA4C,IAAI,CAAC,YAAY,GAAG,CAAC,CAAA;QACvG,CAAC;QAED,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;IACvC,CAAC;IAED;;;;;;;;;;OAUG;IACI,GAAG,CAAC,KAAwB,EAAE,MAAM,GAAG,CAAC;QAC9C,MAAM,UAAU,GAAG,MAAM,GAAG,KAAK,CAAC,MAAM,CAAA;QAExC,IAAI,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;YACpC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;QACtB,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;QAE7B,IAAI,UAAU,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;YACpC,IAAI,CAAC,YAAY,GAAG,UAAU,CAAA;QAC/B,CAAC;QAED,OAAO,UAAU,CAAA;IAClB,CAAC;CACD"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license MIT
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
import type { PathBuilderLike } from "path-ts";
|
|
7
|
+
import type { ByteRange } from "../internal/shared.js";
|
|
8
|
+
import { type MatchResult, type WasmRangeScanResult } from "./wasm_module.js";
|
|
9
|
+
export declare function isArrayLike<T>(input: unknown): input is ArrayLike<T>;
|
|
10
|
+
export type CharacterSequenceInput = number | string | DataView | ArrayBuffer | Buffer | Iterable<number> | PathBuilderLike;
|
|
11
|
+
export declare const Delimiters: {
|
|
12
|
+
readonly Null: 0;
|
|
13
|
+
readonly LineFeed: 10;
|
|
14
|
+
readonly CarriageReturn: 13;
|
|
15
|
+
readonly Comma: 44;
|
|
16
|
+
readonly Tab: 9;
|
|
17
|
+
readonly Space: 32;
|
|
18
|
+
readonly One: 49;
|
|
19
|
+
readonly Zero: 48;
|
|
20
|
+
readonly DoubleQuote: 34;
|
|
21
|
+
readonly RecordSeparator: 30;
|
|
22
|
+
readonly Pipe: 124;
|
|
23
|
+
};
|
|
24
|
+
export declare const VisibleDelimiterMap: Map<number, string>;
|
|
25
|
+
export declare function debugAsVisibleCharacters(delimiter: Uint8Array): string;
|
|
26
|
+
export declare function normalizeCharacterInput(input: CharacterSequenceInput): Uint8Array;
|
|
27
|
+
export declare class CharacterSequence extends Uint8Array {
|
|
28
|
+
#private;
|
|
29
|
+
/**
|
|
30
|
+
* Resolve once the WASM SIMD scanner has finished loading, yielding whether it is active.
|
|
31
|
+
*
|
|
32
|
+
* The module loads asynchronously, so synchronous callers (`Spliterator.fromSync`, `CSVSpliterator.from`) that run to
|
|
33
|
+
* completion in a single tick would otherwise always fall back to the JS scanner. Await this first to opt into SIMD
|
|
34
|
+
* acceleration.
|
|
35
|
+
*/
|
|
36
|
+
static whenReady(): Promise<boolean>;
|
|
37
|
+
search(haystack: Uint8Array, start?: number, end?: number): number;
|
|
38
|
+
searchAll(haystack: Uint8Array, start?: number, end?: number): ByteRange[];
|
|
39
|
+
/**
|
|
40
|
+
* Scan completed ranges in one bounded, resumable WASM call.
|
|
41
|
+
*
|
|
42
|
+
* This is the low-allocation streaming primitive: unlike {@link searchMatches}, it carries quote state and range
|
|
43
|
+
* boundaries through the native scan and exposes the packed result view directly. The returned view aliases shared
|
|
44
|
+
* WASM memory and must be consumed before another scanner call.
|
|
45
|
+
*
|
|
46
|
+
* Returns `null` when the SIMD module is unavailable, the delimiter/quote is not one byte, or the buffer is below the
|
|
47
|
+
* WASM threshold. Callers must retain their existing JavaScript path as the fallback.
|
|
48
|
+
*/
|
|
49
|
+
scanRanges(haystack: Uint8Array, state: {
|
|
50
|
+
scanCursor: number;
|
|
51
|
+
pendingSliceStart: number;
|
|
52
|
+
insideQuotes: boolean;
|
|
53
|
+
}, end?: number, quotePattern?: Uint8Array, maxRanges?: number): WasmRangeScanResult | null;
|
|
54
|
+
/**
|
|
55
|
+
* Scan for two patterns simultaneously (delimiter + quote) for CSV parsing.
|
|
56
|
+
*
|
|
57
|
+
* Returns sorted MatchResult[] with patternId 0=delimiter, 1=quote. Uses WASM SIMD double-scan when available; JS
|
|
58
|
+
* fallback otherwise.
|
|
59
|
+
*/
|
|
60
|
+
searchMatches(haystack: Uint8Array, quotePattern: Uint8Array, start?: number, end?: number): MatchResult[];
|
|
61
|
+
/**
|
|
62
|
+
* Adopt a pattern as a sequence, reusing it when it already is one.
|
|
63
|
+
*
|
|
64
|
+
* Constructing a sequence builds a 256-entry skip table, so wrapping unconditionally puts that allocation on every
|
|
65
|
+
* call of a per-row scan. Every in-tree caller of {@linkcode searchMatches} already holds a long-lived sequence for
|
|
66
|
+
* its quote pattern.
|
|
67
|
+
*/
|
|
68
|
+
static asSequence(pattern: Uint8Array): CharacterSequence;
|
|
69
|
+
decode(encoding?: string): string;
|
|
70
|
+
constructor(input?: CharacterSequenceInput);
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=CharacterSequence.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CharacterSequence.d.ts","sourceRoot":"","sources":["../../../lib/core/CharacterSequence.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAIN,KAAK,WAAW,EAGhB,KAAK,mBAAmB,EACxB,MAAM,kBAAkB,CAAA;AAEzB,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,CAAC,CAAC,CAAC,CAEpE;AAED,MAA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H,OAAc,UAAU,CAAC,OAAO,EAAE,UAAU,GAAG,iBAAiB,CAE/D;IAEM,MAAM,CAAC,QAAQ,SAAS,GAAG,MAAM,CAEvC;IAED,YAAY,KAAK,GAAE,sBAA4C,EAW9D;CACD"}
|
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license MIT
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
import { loadWasmModule, WASM_MAX_RESULTS, WASM_THRESHOLD, } from "./wasm_module.js";
|
|
7
|
+
export function isArrayLike(input) {
|
|
8
|
+
return Boolean(input && typeof input === "object" && "length" in input);
|
|
9
|
+
}
|
|
10
|
+
export const Delimiters = {
|
|
11
|
+
Null: 0,
|
|
12
|
+
LineFeed: 10,
|
|
13
|
+
CarriageReturn: 13,
|
|
14
|
+
Comma: 44,
|
|
15
|
+
Tab: 9,
|
|
16
|
+
Space: 32,
|
|
17
|
+
One: 49,
|
|
18
|
+
Zero: 48,
|
|
19
|
+
DoubleQuote: 34,
|
|
20
|
+
RecordSeparator: 30,
|
|
21
|
+
Pipe: 124,
|
|
22
|
+
};
|
|
23
|
+
export const VisibleDelimiterMap = new Map([
|
|
24
|
+
[Delimiters.LineFeed, "\u2424"],
|
|
25
|
+
[Delimiters.CarriageReturn, "\u240D"],
|
|
26
|
+
[Delimiters.Comma, "-"],
|
|
27
|
+
[Delimiters.Tab, "\u2409"],
|
|
28
|
+
[Delimiters.Space, "\u2420"],
|
|
29
|
+
[Delimiters.DoubleQuote, '"'],
|
|
30
|
+
[Delimiters.RecordSeparator, "\u241E"],
|
|
31
|
+
[Delimiters.Null, "\u2400"],
|
|
32
|
+
]);
|
|
33
|
+
export function debugAsVisibleCharacters(delimiter) {
|
|
34
|
+
return Array.from(delimiter)
|
|
35
|
+
.map((c) => VisibleDelimiterMap.get(c) ?? String.fromCharCode(c))
|
|
36
|
+
.join("");
|
|
37
|
+
}
|
|
38
|
+
const encoder = new TextEncoder();
|
|
39
|
+
export function normalizeCharacterInput(input) {
|
|
40
|
+
switch (typeof input) {
|
|
41
|
+
case "number":
|
|
42
|
+
if (!Number.isInteger(input))
|
|
43
|
+
throw new TypeError(`Numeric delimiters must be integers.`);
|
|
44
|
+
return Uint8Array.from([input]);
|
|
45
|
+
case "string":
|
|
46
|
+
return encoder.encode(input);
|
|
47
|
+
case "object":
|
|
48
|
+
// Typed arrays and buffers are adopted by reference where possible — a multi-megabyte
|
|
49
|
+
// haystack must not be copied on the way in. `ArrayBuffer` and `DataView` are declared
|
|
50
|
+
// inputs and previously threw: neither carries `length`, and neither is iterable.
|
|
51
|
+
if (input instanceof Uint8Array)
|
|
52
|
+
return input;
|
|
53
|
+
if (ArrayBuffer.isView(input))
|
|
54
|
+
return new Uint8Array(input.buffer, input.byteOffset, input.byteLength);
|
|
55
|
+
if (input instanceof ArrayBuffer)
|
|
56
|
+
return new Uint8Array(input);
|
|
57
|
+
// A plain array-like (`number[]`) is NOT a Uint8Array — copy it rather than hand back
|
|
58
|
+
// something whose `search` would index a boxed array.
|
|
59
|
+
if (isArrayLike(input))
|
|
60
|
+
return Uint8Array.from(input);
|
|
61
|
+
if (Symbol.iterator in input)
|
|
62
|
+
return Uint8Array.from(input);
|
|
63
|
+
throw new TypeError(`Invalid delimiter type.`);
|
|
64
|
+
default:
|
|
65
|
+
throw new TypeError(`Invalid delimiter type.`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function ensureWasmCapacity(memory, required) {
|
|
69
|
+
if (required <= memory.buffer.byteLength)
|
|
70
|
+
return;
|
|
71
|
+
const pages = Math.ceil((required - memory.buffer.byteLength) / 65_536);
|
|
72
|
+
memory.grow(pages);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Round `offset` up to the next multiple of 4 — `Int32Array` views require a 4-byte-aligned base.
|
|
76
|
+
*/
|
|
77
|
+
function alignTo4(offset) {
|
|
78
|
+
return Math.ceil(offset / 4) * 4;
|
|
79
|
+
}
|
|
80
|
+
export class CharacterSequence extends Uint8Array {
|
|
81
|
+
#skipIndex;
|
|
82
|
+
static #wasmScanner;
|
|
83
|
+
static #wasmHaystack = null;
|
|
84
|
+
static #wasmPatternOffset = 0;
|
|
85
|
+
static #wasmReadyPromise;
|
|
86
|
+
static #loadWasm() {
|
|
87
|
+
if (CharacterSequence.#wasmReadyPromise === undefined) {
|
|
88
|
+
// Reflect "load in progress" synchronously so search()'s fast path stops
|
|
89
|
+
// re-triggering loads on every call while the module compiles.
|
|
90
|
+
if (CharacterSequence.#wasmScanner === undefined) {
|
|
91
|
+
CharacterSequence.#wasmScanner = null;
|
|
92
|
+
}
|
|
93
|
+
CharacterSequence.#wasmReadyPromise = loadWasmModule().then((mod) => {
|
|
94
|
+
CharacterSequence.#wasmScanner = mod;
|
|
95
|
+
return mod;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
return CharacterSequence.#wasmReadyPromise;
|
|
99
|
+
}
|
|
100
|
+
static #ensureWasm() {
|
|
101
|
+
void CharacterSequence.#loadWasm();
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Resolve once the WASM SIMD scanner has finished loading, yielding whether it is active.
|
|
105
|
+
*
|
|
106
|
+
* The module loads asynchronously, so synchronous callers (`Spliterator.fromSync`, `CSVSpliterator.from`) that run to
|
|
107
|
+
* completion in a single tick would otherwise always fall back to the JS scanner. Await this first to opt into SIMD
|
|
108
|
+
* acceleration.
|
|
109
|
+
*/
|
|
110
|
+
static whenReady() {
|
|
111
|
+
return CharacterSequence.#loadWasm().then((mod) => mod !== null);
|
|
112
|
+
}
|
|
113
|
+
search(haystack, start = 0, end = haystack.length) {
|
|
114
|
+
const sequenceLength = this.length;
|
|
115
|
+
// Single-byte delimiters (newline, comma, tab — the common case) are far faster via
|
|
116
|
+
// the native indexOf than the per-match Boyer-Moore-Horspool loop below. indexOf has
|
|
117
|
+
// no end bound, so clamp the result to keep `end` exclusive.
|
|
118
|
+
if (sequenceLength === 1) {
|
|
119
|
+
const index = haystack.indexOf(this[0], start);
|
|
120
|
+
return index !== -1 && index < end ? index : -1;
|
|
121
|
+
}
|
|
122
|
+
if (sequenceLength > 1 && end - start >= WASM_THRESHOLD) {
|
|
123
|
+
const wasm = CharacterSequence.#wasmScanner;
|
|
124
|
+
if (wasm) {
|
|
125
|
+
// Cache the *entire* haystack at offset 0 (so WASM byte `i` === `haystack[i]`),
|
|
126
|
+
// keyed by identity. This keeps repeated searches over the same source (the
|
|
127
|
+
// Spliterator fill loop) copy-free while staying correct for any start/end — the
|
|
128
|
+
// previous "copy [start,end)" scheme mis-mapped offsets when start !== 0 and
|
|
129
|
+
// silently ignored a shrinking `end`.
|
|
130
|
+
if (haystack !== CharacterSequence.#wasmHaystack) {
|
|
131
|
+
const fullLen = haystack.length;
|
|
132
|
+
const totalNeeded = fullLen + sequenceLength;
|
|
133
|
+
ensureWasmCapacity(wasm.memory, totalNeeded);
|
|
134
|
+
const buffer = new Uint8Array(wasm.memory.buffer, 0, totalNeeded);
|
|
135
|
+
buffer.set(haystack, 0);
|
|
136
|
+
buffer.set(this, fullLen);
|
|
137
|
+
CharacterSequence.#wasmHaystack = haystack;
|
|
138
|
+
CharacterSequence.#wasmPatternOffset = fullLen;
|
|
139
|
+
}
|
|
140
|
+
const result = wasm.findDelimiter(start, end - start, CharacterSequence.#wasmPatternOffset, sequenceLength);
|
|
141
|
+
return result >= 0 ? start + result : -1;
|
|
142
|
+
}
|
|
143
|
+
if (CharacterSequence.#wasmScanner === undefined) {
|
|
144
|
+
CharacterSequence.#ensureWasm();
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
CharacterSequence.#wasmHaystack = null;
|
|
148
|
+
let startIndex = start;
|
|
149
|
+
while (startIndex <= end - sequenceLength) {
|
|
150
|
+
let lastIndex = sequenceLength - 1;
|
|
151
|
+
while (lastIndex >= 0 && this[lastIndex] === haystack[startIndex + lastIndex]) {
|
|
152
|
+
lastIndex--;
|
|
153
|
+
}
|
|
154
|
+
if (lastIndex < 0)
|
|
155
|
+
return startIndex;
|
|
156
|
+
startIndex += this.#skipIndex[haystack[startIndex + sequenceLength - 1]];
|
|
157
|
+
}
|
|
158
|
+
return -1;
|
|
159
|
+
}
|
|
160
|
+
searchAll(haystack, start = 0, end = haystack.length) {
|
|
161
|
+
const sequenceLength = this.length;
|
|
162
|
+
const haystackLen = end - start;
|
|
163
|
+
if (sequenceLength >= 1 && haystackLen >= WASM_THRESHOLD) {
|
|
164
|
+
const wasm = CharacterSequence.#wasmScanner;
|
|
165
|
+
if (wasm) {
|
|
166
|
+
const resultsOffset = alignTo4(haystackLen + sequenceLength);
|
|
167
|
+
const resultsSize = WASM_MAX_RESULTS * 2 * 4;
|
|
168
|
+
const totalNeeded = resultsOffset + resultsSize;
|
|
169
|
+
ensureWasmCapacity(wasm.memory, totalNeeded);
|
|
170
|
+
const buffer = new Uint8Array(wasm.memory.buffer, 0, totalNeeded);
|
|
171
|
+
buffer.set(haystack.subarray(start, end), 0);
|
|
172
|
+
buffer.set(this, haystackLen);
|
|
173
|
+
// We just overwrote offset 0; any haystack search() cached there is now stale.
|
|
174
|
+
CharacterSequence.#wasmHaystack = null;
|
|
175
|
+
const count = wasm.findAllDelimiters(0, haystackLen, haystackLen, sequenceLength, resultsOffset, WASM_MAX_RESULTS);
|
|
176
|
+
const rv = new Int32Array(wasm.memory.buffer, resultsOffset, count * 2);
|
|
177
|
+
const ranges = [];
|
|
178
|
+
for (let i = 0; i < count; i++) {
|
|
179
|
+
ranges.push([start + rv[i * 2], start + rv[i * 2 + 1]]);
|
|
180
|
+
}
|
|
181
|
+
// A full results buffer means the scan may have hit the cap and dropped
|
|
182
|
+
// trailing delimiters; fall back to the uncapped JS scan rather than truncate.
|
|
183
|
+
if (count < WASM_MAX_RESULTS)
|
|
184
|
+
return ranges;
|
|
185
|
+
}
|
|
186
|
+
if (CharacterSequence.#wasmScanner === undefined) {
|
|
187
|
+
CharacterSequence.#ensureWasm();
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
const ranges = [];
|
|
191
|
+
let searchStart = start, rangeStart = start;
|
|
192
|
+
while (searchStart <= end - sequenceLength) {
|
|
193
|
+
let lastIndex = sequenceLength - 1;
|
|
194
|
+
while (lastIndex >= 0 && this[lastIndex] === haystack[searchStart + lastIndex]) {
|
|
195
|
+
lastIndex--;
|
|
196
|
+
}
|
|
197
|
+
if (lastIndex < 0) {
|
|
198
|
+
ranges.push([rangeStart, searchStart]);
|
|
199
|
+
searchStart += sequenceLength;
|
|
200
|
+
rangeStart = searchStart;
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
searchStart += this.#skipIndex[haystack[searchStart + sequenceLength - 1]];
|
|
204
|
+
}
|
|
205
|
+
if (rangeStart <= end) {
|
|
206
|
+
ranges.push([rangeStart, end]);
|
|
207
|
+
}
|
|
208
|
+
return ranges;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Scan completed ranges in one bounded, resumable WASM call.
|
|
212
|
+
*
|
|
213
|
+
* This is the low-allocation streaming primitive: unlike {@link searchMatches}, it carries quote state and range
|
|
214
|
+
* boundaries through the native scan and exposes the packed result view directly. The returned view aliases shared
|
|
215
|
+
* WASM memory and must be consumed before another scanner call.
|
|
216
|
+
*
|
|
217
|
+
* Returns `null` when the SIMD module is unavailable, the delimiter/quote is not one byte, or the buffer is below the
|
|
218
|
+
* WASM threshold. Callers must retain their existing JavaScript path as the fallback.
|
|
219
|
+
*/
|
|
220
|
+
scanRanges(haystack, state, end = haystack.length, quotePattern, maxRanges = WASM_MAX_RESULTS) {
|
|
221
|
+
if (this.length !== 1 || (quotePattern && quotePattern.length !== 1) || end < WASM_THRESHOLD || maxRanges < 1) {
|
|
222
|
+
return null;
|
|
223
|
+
}
|
|
224
|
+
const wasm = CharacterSequence.#wasmScanner;
|
|
225
|
+
if (!wasm) {
|
|
226
|
+
if (CharacterSequence.#wasmScanner === undefined) {
|
|
227
|
+
CharacterSequence.#ensureWasm();
|
|
228
|
+
}
|
|
229
|
+
return null;
|
|
230
|
+
}
|
|
231
|
+
const resultsOffset = alignTo4(end);
|
|
232
|
+
const resultValueCount = 3 + maxRanges * 2;
|
|
233
|
+
const totalNeeded = resultsOffset + resultValueCount * Int32Array.BYTES_PER_ELEMENT;
|
|
234
|
+
ensureWasmCapacity(wasm.memory, totalNeeded);
|
|
235
|
+
new Uint8Array(wasm.memory.buffer, 0, end).set(haystack.subarray(0, end));
|
|
236
|
+
CharacterSequence.#wasmHaystack = null;
|
|
237
|
+
const count = wasm.scanDelimitedRanges(0, end, state.scanCursor, state.pendingSliceStart, this[0], quotePattern?.[0] ?? -1, state.insideQuotes ? 1 : 0, resultsOffset, maxRanges);
|
|
238
|
+
const result = new Int32Array(wasm.memory.buffer, resultsOffset, 3 + count * 2);
|
|
239
|
+
return {
|
|
240
|
+
ranges: result.subarray(3),
|
|
241
|
+
count,
|
|
242
|
+
scanCursor: result[0],
|
|
243
|
+
pendingSliceStart: result[1],
|
|
244
|
+
insideQuotes: result[2] === 1,
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Scan for two patterns simultaneously (delimiter + quote) for CSV parsing.
|
|
249
|
+
*
|
|
250
|
+
* Returns sorted MatchResult[] with patternId 0=delimiter, 1=quote. Uses WASM SIMD double-scan when available; JS
|
|
251
|
+
* fallback otherwise.
|
|
252
|
+
*/
|
|
253
|
+
searchMatches(haystack, quotePattern, start = 0, end = haystack.length) {
|
|
254
|
+
const delimiterLen = this.length;
|
|
255
|
+
const quoteLen = quotePattern.length;
|
|
256
|
+
const haystackLen = end - start;
|
|
257
|
+
if (delimiterLen === 0 || haystackLen === 0)
|
|
258
|
+
return [];
|
|
259
|
+
const wasm = CharacterSequence.#wasmScanner;
|
|
260
|
+
if (wasm && haystackLen >= WASM_THRESHOLD) {
|
|
261
|
+
const patternsSize = delimiterLen + quoteLen;
|
|
262
|
+
const resultsOffset = alignTo4(haystackLen + patternsSize);
|
|
263
|
+
const resultsSize = WASM_MAX_RESULTS * 2 * 4;
|
|
264
|
+
const totalNeeded = resultsOffset + resultsSize;
|
|
265
|
+
ensureWasmCapacity(wasm.memory, totalNeeded);
|
|
266
|
+
const buffer = new Uint8Array(wasm.memory.buffer, 0, totalNeeded);
|
|
267
|
+
buffer.set(haystack.subarray(start, end), 0);
|
|
268
|
+
buffer.set(this, haystackLen);
|
|
269
|
+
buffer.set(quotePattern, haystackLen + delimiterLen);
|
|
270
|
+
// We just overwrote offset 0; any haystack search() cached there is now stale.
|
|
271
|
+
CharacterSequence.#wasmHaystack = null;
|
|
272
|
+
const count = wasm.findAllMatches(0, haystackLen, haystackLen, delimiterLen, quoteLen, resultsOffset, WASM_MAX_RESULTS);
|
|
273
|
+
const rv = new Int32Array(wasm.memory.buffer, resultsOffset, count * 2);
|
|
274
|
+
const matches = [];
|
|
275
|
+
for (let i = 0; i < count; i++) {
|
|
276
|
+
matches.push({ offset: start + rv[i * 2], patternId: rv[i * 2 + 1] });
|
|
277
|
+
}
|
|
278
|
+
// A full results buffer means the scan may have hit the cap and dropped
|
|
279
|
+
// trailing matches; fall back to the uncapped JS scan rather than truncate.
|
|
280
|
+
if (count < WASM_MAX_RESULTS)
|
|
281
|
+
return matches;
|
|
282
|
+
}
|
|
283
|
+
if (CharacterSequence.#wasmScanner === undefined) {
|
|
284
|
+
CharacterSequence.#ensureWasm();
|
|
285
|
+
}
|
|
286
|
+
// JS fallback: scan both patterns independently and merge in offset order. Both
|
|
287
|
+
// searches honour `end` exclusivity and handle multi-byte patterns (the quote is
|
|
288
|
+
// wrapped in a CharacterSequence so it isn't limited to a single byte).
|
|
289
|
+
//
|
|
290
|
+
// Each pattern's next hit is carried across iterations and re-searched only once the
|
|
291
|
+
// cursor has passed it. Re-searching both every iteration is quadratic: a `search` that
|
|
292
|
+
// finds nothing has scanned all the way to `end` to say so, and a source containing no
|
|
293
|
+
// quote at all pays that whole scan once per delimiter. A `-1` is final for the rest of
|
|
294
|
+
// the range and must never be re-searched.
|
|
295
|
+
const matches = [];
|
|
296
|
+
const quoteSeq = CharacterSequence.asSequence(quotePattern);
|
|
297
|
+
let searchStart = start;
|
|
298
|
+
let delimiterIndex = this.search(haystack, searchStart, end);
|
|
299
|
+
let quoteIndex = quoteSeq.search(haystack, searchStart, end);
|
|
300
|
+
while (delimiterIndex >= 0 || quoteIndex >= 0) {
|
|
301
|
+
if (delimiterIndex >= 0 && (quoteIndex < 0 || delimiterIndex <= quoteIndex)) {
|
|
302
|
+
matches.push({ offset: delimiterIndex, patternId: 0 });
|
|
303
|
+
searchStart = delimiterIndex + delimiterLen;
|
|
304
|
+
delimiterIndex = this.search(haystack, searchStart, end);
|
|
305
|
+
// Patterns longer than a byte can overlap, so a carried quote hit that the delimiter's
|
|
306
|
+
// span just swallowed is stale. Single-byte patterns never enter this branch.
|
|
307
|
+
if (quoteIndex >= 0 && quoteIndex < searchStart) {
|
|
308
|
+
quoteIndex = quoteSeq.search(haystack, searchStart, end);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
else {
|
|
312
|
+
matches.push({ offset: quoteIndex, patternId: 1 });
|
|
313
|
+
searchStart = quoteIndex + quoteLen;
|
|
314
|
+
quoteIndex = quoteSeq.search(haystack, searchStart, end);
|
|
315
|
+
if (delimiterIndex >= 0 && delimiterIndex < searchStart) {
|
|
316
|
+
delimiterIndex = this.search(haystack, searchStart, end);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
return matches;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Adopt a pattern as a sequence, reusing it when it already is one.
|
|
324
|
+
*
|
|
325
|
+
* Constructing a sequence builds a 256-entry skip table, so wrapping unconditionally puts that allocation on every
|
|
326
|
+
* call of a per-row scan. Every in-tree caller of {@linkcode searchMatches} already holds a long-lived sequence for
|
|
327
|
+
* its quote pattern.
|
|
328
|
+
*/
|
|
329
|
+
static asSequence(pattern) {
|
|
330
|
+
return pattern instanceof CharacterSequence ? pattern : new CharacterSequence(pattern);
|
|
331
|
+
}
|
|
332
|
+
decode(encoding = "utf8") {
|
|
333
|
+
return new TextDecoder(encoding).decode(this);
|
|
334
|
+
}
|
|
335
|
+
constructor(input = Delimiters.LineFeed) {
|
|
336
|
+
const bytes = normalizeCharacterInput(input);
|
|
337
|
+
super(bytes);
|
|
338
|
+
// `new Array(256).fill(…)` rather than `Array.from({length: 256}, …)`: same result, no
|
|
339
|
+
// per-entry callback, and this runs for every sequence constructed.
|
|
340
|
+
// oxlint-disable-next-line unicorn/no-new-array
|
|
341
|
+
this.#skipIndex = new Array(256).fill(this.length);
|
|
342
|
+
for (let i = 0; i < this.length - 1; i++) {
|
|
343
|
+
this.#skipIndex[this[i]] = this.length - 1 - i;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
//# sourceMappingURL=CharacterSequence.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CharacterSequence.js","sourceRoot":"","sources":["../../../lib/core/CharacterSequence.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,EACN,cAAc,EACd,gBAAgB,EAChB,cAAc,GAKd,MAAM,kBAAkB,CAAA;AAEzB,MAAM,UAAU,WAAW,CAAI,KAAc;IAC5C,OAAO,OAAO,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,QAAQ,IAAI,KAAK,CAAC,CAAA;AACxE,CAAC;AAWD,MAAM,CAAC,MAAM,UAAU,GAAG;IACzB,IAAI,EAAE,CAAC;IACP,QAAQ,EAAE,EAAE;IACZ,cAAc,EAAE,EAAE;IAClB,KAAK,EAAE,EAAE;IACT,GAAG,EAAE,CAAC;IACN,KAAK,EAAE,EAAE;IACT,GAAG,EAAE,EAAE;IACP,IAAI,EAAE,EAAE;IACR,WAAW,EAAE,EAAE;IACf,eAAe,EAAE,EAAE;IACnB,IAAI,EAAE,GAAG;CACiC,CAAA;AAE3C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