spliterator 6.2.0 → 6.3.1
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/out/lib/core/AsyncSpliterator.d.ts +1 -1
- package/out/lib/core/AsyncSpliterator.d.ts.map +1 -1
- package/out/lib/core/AsyncSpliterator.js +2 -2
- package/out/lib/core/AsyncSpliterator.js.map +1 -1
- package/out/lib/core/SlidingWindow.d.ts +1 -1
- package/out/lib/core/SlidingWindow.d.ts.map +1 -1
- package/out/lib/core/SlidingWindow.js.map +1 -1
- package/out/lib/core/Spliterator.d.ts +1 -1
- package/out/lib/core/Spliterator.d.ts.map +1 -1
- package/out/lib/core/Spliterator.js +1 -1
- package/out/lib/core/Spliterator.js.map +1 -1
- package/out/lib/formats/CSVSpliterator.d.ts +2 -2
- package/out/lib/formats/CSVSpliterator.d.ts.map +1 -1
- package/out/lib/formats/CSVSpliterator.js +92 -1
- package/out/lib/formats/CSVSpliterator.js.map +1 -1
- package/out/lib/formats/XLSXSpliterator.d.ts +1 -1
- package/out/lib/formats/XLSXSpliterator.d.ts.map +1 -1
- package/package.json +2 -3
- package/out/lib/AsyncSequence.d.ts +0 -180
- package/out/lib/AsyncSequence.d.ts.map +0 -1
- package/out/lib/AsyncSequence.js +0 -432
- package/out/lib/AsyncSequence.js.map +0 -1
- package/out/lib/AsyncSpliterator.d.ts +0 -227
- package/out/lib/AsyncSpliterator.d.ts.map +0 -1
- package/out/lib/AsyncSpliterator.js +0 -510
- package/out/lib/AsyncSpliterator.js.map +0 -1
- package/out/lib/BufferController.d.ts +0 -77
- package/out/lib/BufferController.d.ts.map +0 -1
- package/out/lib/BufferController.js +0 -118
- package/out/lib/BufferController.js.map +0 -1
- package/out/lib/CSVSpliterator.d.ts +0 -131
- package/out/lib/CSVSpliterator.d.ts.map +0 -1
- package/out/lib/CSVSpliterator.js +0 -172
- package/out/lib/CSVSpliterator.js.map +0 -1
- package/out/lib/CharacterSequence.d.ts +0 -72
- package/out/lib/CharacterSequence.d.ts.map +0 -1
- package/out/lib/CharacterSequence.js +0 -347
- package/out/lib/CharacterSequence.js.map +0 -1
- package/out/lib/CompositeDataView.d.ts +0 -111
- package/out/lib/CompositeDataView.d.ts.map +0 -1
- package/out/lib/CompositeDataView.js +0 -241
- package/out/lib/CompositeDataView.js.map +0 -1
- package/out/lib/IndexQueue.d.ts +0 -48
- package/out/lib/IndexQueue.d.ts.map +0 -1
- package/out/lib/IndexQueue.js +0 -111
- package/out/lib/IndexQueue.js.map +0 -1
- package/out/lib/JSONSpliterator.d.ts +0 -44
- package/out/lib/JSONSpliterator.d.ts.map +0 -1
- package/out/lib/JSONSpliterator.js +0 -77
- package/out/lib/JSONSpliterator.js.map +0 -1
- package/out/lib/PSVSpliterator.d.ts +0 -21
- package/out/lib/PSVSpliterator.d.ts.map +0 -1
- package/out/lib/PSVSpliterator.js +0 -22
- package/out/lib/PSVSpliterator.js.map +0 -1
- package/out/lib/SlidingWindow.d.ts +0 -47
- package/out/lib/SlidingWindow.d.ts.map +0 -1
- package/out/lib/SlidingWindow.js +0 -63
- package/out/lib/SlidingWindow.js.map +0 -1
- package/out/lib/Spliterator.d.ts +0 -96
- package/out/lib/Spliterator.d.ts.map +0 -1
- package/out/lib/Spliterator.js +0 -330
- package/out/lib/Spliterator.js.map +0 -1
- package/out/lib/TSVSpliterator.d.ts +0 -21
- package/out/lib/TSVSpliterator.d.ts.map +0 -1
- package/out/lib/TSVSpliterator.js +0 -22
- package/out/lib/TSVSpliterator.js.map +0 -1
- package/out/lib/TextSpliterator.d.ts +0 -53
- package/out/lib/TextSpliterator.d.ts.map +0 -1
- package/out/lib/TextSpliterator.js +0 -67
- package/out/lib/TextSpliterator.js.map +0 -1
- package/out/lib/XLSXSpliterator.d.ts +0 -143
- package/out/lib/XLSXSpliterator.d.ts.map +0 -1
- package/out/lib/XLSXSpliterator.js +0 -161
- package/out/lib/XLSXSpliterator.js.map +0 -1
- package/out/lib/adaptive-source.d.ts +0 -39
- package/out/lib/adaptive-source.d.ts.map +0 -1
- package/out/lib/adaptive-source.js +0 -95
- package/out/lib/adaptive-source.js.map +0 -1
- package/out/lib/casing.d.ts +0 -27
- package/out/lib/casing.d.ts.map +0 -1
- package/out/lib/casing.js +0 -68
- package/out/lib/casing.js.map +0 -1
- package/out/lib/chunks.d.ts +0 -20
- package/out/lib/chunks.d.ts.map +0 -1
- package/out/lib/chunks.js +0 -36
- package/out/lib/chunks.js.map +0 -1
- package/out/lib/merge-async-iterators.d.ts +0 -12
- package/out/lib/merge-async-iterators.d.ts.map +0 -1
- package/out/lib/merge-async-iterators.js +0 -39
- package/out/lib/merge-async-iterators.js.map +0 -1
- package/out/lib/parallel-map-runtime.d.ts +0 -22
- package/out/lib/parallel-map-runtime.d.ts.map +0 -1
- package/out/lib/parallel-map-runtime.js +0 -60
- package/out/lib/parallel-map-runtime.js.map +0 -1
- package/out/lib/parallel-map-worker-entry.d.ts +0 -11
- package/out/lib/parallel-map-worker-entry.d.ts.map +0 -1
- package/out/lib/parallel-map-worker-entry.js +0 -41
- package/out/lib/parallel-map-worker-entry.js.map +0 -1
- package/out/lib/parallel-map-workers.d.ts +0 -57
- package/out/lib/parallel-map-workers.d.ts.map +0 -1
- package/out/lib/parallel-map-workers.js +0 -82
- package/out/lib/parallel-map-workers.js.map +0 -1
- package/out/lib/parallel-map.d.ts +0 -28
- package/out/lib/parallel-map.d.ts.map +0 -1
- package/out/lib/parallel-map.js +0 -30
- package/out/lib/parallel-map.js.map +0 -1
- package/out/lib/pivot.d.ts +0 -30
- package/out/lib/pivot.d.ts.map +0 -1
- package/out/lib/pivot.js +0 -47
- package/out/lib/pivot.js.map +0 -1
- package/out/lib/row-emitters.d.ts +0 -35
- package/out/lib/row-emitters.d.ts.map +0 -1
- package/out/lib/row-emitters.js +0 -50
- package/out/lib/row-emitters.js.map +0 -1
- package/out/lib/segment-runtime.d.ts +0 -27
- package/out/lib/segment-runtime.d.ts.map +0 -1
- package/out/lib/segment-runtime.js +0 -41
- package/out/lib/segment-runtime.js.map +0 -1
- package/out/lib/segment-worker-entry.d.ts +0 -10
- package/out/lib/segment-worker-entry.d.ts.map +0 -1
- package/out/lib/segment-worker-entry.js +0 -59
- package/out/lib/segment-worker-entry.js.map +0 -1
- package/out/lib/segment-workers.d.ts +0 -56
- package/out/lib/segment-workers.d.ts.map +0 -1
- package/out/lib/segment-workers.js +0 -110
- package/out/lib/segment-workers.js.map +0 -1
- package/out/lib/segments.d.ts +0 -31
- package/out/lib/segments.d.ts.map +0 -1
- package/out/lib/segments.js +0 -52
- package/out/lib/segments.js.map +0 -1
- package/out/lib/shared.d.ts +0 -155
- package/out/lib/shared.d.ts.map +0 -1
- package/out/lib/shared.js +0 -41
- package/out/lib/shared.js.map +0 -1
- package/out/lib/take.d.ts +0 -42
- package/out/lib/take.d.ts.map +0 -1
- package/out/lib/take.js +0 -101
- package/out/lib/take.js.map +0 -1
- package/out/lib/utils.d.ts +0 -37
- package/out/lib/utils.d.ts.map +0 -1
- package/out/lib/utils.js +0 -39
- package/out/lib/utils.js.map +0 -1
- package/out/lib/wasm_base64.d.ts +0 -19
- package/out/lib/wasm_base64.d.ts.map +0 -1
- package/out/lib/wasm_base64.js +0 -19
- package/out/lib/wasm_base64.js.map +0 -1
- package/out/lib/wasm_module.d.ts +0 -57
- package/out/lib/wasm_module.d.ts.map +0 -1
- package/out/lib/wasm_module.js +0 -34
- package/out/lib/wasm_module.js.map +0 -1
- package/out/lib/writer.d.ts +0 -45
- package/out/lib/writer.d.ts.map +0 -1
- package/out/lib/writer.js +0 -57
- package/out/lib/writer.js.map +0 -1
- package/out/lib/zip.d.ts +0 -33
- package/out/lib/zip.d.ts.map +0 -1
- package/out/lib/zip.js +0 -59
- package/out/lib/zip.js.map +0 -1
- package/out/node/cli/parse-args.d.ts +0 -120
- package/out/node/cli/parse-args.d.ts.map +0 -1
- package/out/node/cli/parse-args.js +0 -118
- package/out/node/cli/parse-args.js.map +0 -1
|
@@ -1,347 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CharacterSequence.js","sourceRoot":"","sources":["../../lib/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,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAiB;IAC1D,CAAC,UAAU,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC/B,CAAC,UAAU,CAAC,cAAc,EAAE,QAAQ,CAAC;IACrC,CAAC,UAAU,CAAC,KAA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,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YAC1C,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAE,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,GAAG,CAAC,CAAA;QAChD,CAAC;IACF,CAAC;CACD"}
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Sister Software
|
|
3
|
-
* @license MIT
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
*/
|
|
6
|
-
import type { TypedArray } from "./shared.js";
|
|
7
|
-
/**
|
|
8
|
-
* A generic mutable typed array.
|
|
9
|
-
*/
|
|
10
|
-
export interface MutableTypedArray<T extends number | bigint = number | bigint> {
|
|
11
|
-
readonly length: number;
|
|
12
|
-
readonly [n: number]: T;
|
|
13
|
-
set(array: ArrayLike<T>, offset?: number): void;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* A constructor for a mutable typed array.
|
|
17
|
-
*/
|
|
18
|
-
export type MutableTypedArrayConstructor<T extends number | bigint = number | bigint> = new (length: number) => MutableTypedArray<T>;
|
|
19
|
-
/**
|
|
20
|
-
* Locally-defined mirror of the TC39 `RelativeIndexable` interface, which is no longer surfaced by the `ESNext` lib
|
|
21
|
-
* used here.
|
|
22
|
-
*/
|
|
23
|
-
interface RelativeIndexable<T> {
|
|
24
|
-
at(index: number): T | undefined;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Given several contiguous byte arrays, wraps them as if they were flattened into a single buffer.
|
|
28
|
-
*/
|
|
29
|
-
export declare class CompositeDataView<Chunk extends TypedArray = TypedArray> implements Iterable<Chunk[0]>, RelativeIndexable<Chunk[0]> {
|
|
30
|
-
#private;
|
|
31
|
-
constructor(chunks?: Chunk[]);
|
|
32
|
-
/**
|
|
33
|
-
* The combined length of all chunks.
|
|
34
|
-
*
|
|
35
|
-
* @see {@linkcode size} for the number of chunks in the composite buffer.
|
|
36
|
-
*/
|
|
37
|
-
get byteLength(): number;
|
|
38
|
-
/**
|
|
39
|
-
* The number of chunks in the composite buffer.
|
|
40
|
-
*
|
|
41
|
-
* @see {@linkcode byteLength} for the total length of the composite buffer.
|
|
42
|
-
*/
|
|
43
|
-
get size(): number;
|
|
44
|
-
get chunks(): readonly Chunk[];
|
|
45
|
-
/**
|
|
46
|
-
* The underlying buffer of the composite buffer.
|
|
47
|
-
*
|
|
48
|
-
* Note that this is not memoized and will create a new buffer each time it is accessed.
|
|
49
|
-
*/
|
|
50
|
-
get buffer(): Chunk;
|
|
51
|
-
get [Symbol.toStringTag](): string;
|
|
52
|
-
[Symbol.iterator](): Iterator<Chunk[0]>;
|
|
53
|
-
/**
|
|
54
|
-
* Returns the value at the given index, as if the chunks were flattened into a single buffer.
|
|
55
|
-
*/
|
|
56
|
-
at(index: number): Chunk[0];
|
|
57
|
-
/**
|
|
58
|
-
* Push a chunk onto the composite buffer.
|
|
59
|
-
*/
|
|
60
|
-
append(chunk: Chunk): number;
|
|
61
|
-
/**
|
|
62
|
-
* Prepend a chunk before the first chunk in the composite buffer.
|
|
63
|
-
*
|
|
64
|
-
* @returns The new length of the composite buffer.
|
|
65
|
-
*/
|
|
66
|
-
prepend(chunk: Chunk): number;
|
|
67
|
-
/**
|
|
68
|
-
* Remove the most recent chunk from the composite buffer.
|
|
69
|
-
*/
|
|
70
|
-
removeLast(): Chunk | undefined;
|
|
71
|
-
/**
|
|
72
|
-
* Remove the first chunk from the composite buffer.
|
|
73
|
-
*/
|
|
74
|
-
removeFirst(): Chunk | undefined;
|
|
75
|
-
/**
|
|
76
|
-
* Returns a view into the underlying chunks without copying data.
|
|
77
|
-
*/
|
|
78
|
-
subarray(
|
|
79
|
-
/**
|
|
80
|
-
* Element to begin at. The offset is inclusive.
|
|
81
|
-
*/
|
|
82
|
-
begin?: number,
|
|
83
|
-
/**
|
|
84
|
-
* Element to end at. The offset is exclusive. If not provided, the view extends to the end of the buffer.
|
|
85
|
-
*/
|
|
86
|
-
end?: number): Chunk;
|
|
87
|
-
/**
|
|
88
|
-
* Flattens the composite buffer into a single buffer.
|
|
89
|
-
*/
|
|
90
|
-
flat(): Chunk;
|
|
91
|
-
/**
|
|
92
|
-
* Returns a shallow copy of the composite buffer.
|
|
93
|
-
*
|
|
94
|
-
* @see {@linkcode subarray} for a view into the underlying chunks.
|
|
95
|
-
*/
|
|
96
|
-
slice(
|
|
97
|
-
/**
|
|
98
|
-
* Zero-based index at which to begin extraction.
|
|
99
|
-
*
|
|
100
|
-
* If this value is negative, it is treated as `byteLength + begin`.
|
|
101
|
-
*/
|
|
102
|
-
start?: number,
|
|
103
|
-
/**
|
|
104
|
-
* Zero-based index before which to end extraction.
|
|
105
|
-
*
|
|
106
|
-
* If this value is negative, it is treated as `byteLength + end`.
|
|
107
|
-
*/
|
|
108
|
-
end?: number): Chunk;
|
|
109
|
-
}
|
|
110
|
-
export {};
|
|
111
|
-
//# sourceMappingURL=CompositeDataView.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CompositeDataView.d.ts","sourceRoot":"","sources":["../../lib/CompositeDataView.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE7C;;GAEG;AACH,MAAM,WAAW,iBAAiB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM;IAC7E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,EAAE,CAAC,EAAE,MAAM,GAAG,CAAC,CAAA;IACvB,GAAG,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC/C;AAED;;GAEG;AACH,MAAM,MAAM,4BAA4B,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAA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