spliterator 6.2.0 → 6.3.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/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.map +1 -1
- package/out/lib/formats/CSVSpliterator.js +92 -1
- package/out/lib/formats/CSVSpliterator.js.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,241 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Sister Software
|
|
3
|
-
* @license MIT
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Given several contiguous byte arrays, wraps them as if they were flattened into a single buffer.
|
|
8
|
-
*/
|
|
9
|
-
export class CompositeDataView {
|
|
10
|
-
/**
|
|
11
|
-
* The chunks that make up the composite buffer.
|
|
12
|
-
*/
|
|
13
|
-
#chunks = [];
|
|
14
|
-
/**
|
|
15
|
-
* Cached length of the composite buffer.
|
|
16
|
-
*/
|
|
17
|
-
#memoizedByteLength = 0;
|
|
18
|
-
/**
|
|
19
|
-
* Cached chunk offset information for binary search.
|
|
20
|
-
*/
|
|
21
|
-
#chunkOffsets = [];
|
|
22
|
-
/**
|
|
23
|
-
* Helper method to infer the constructor of the chunks.
|
|
24
|
-
*/
|
|
25
|
-
#inferChunkConstructor() {
|
|
26
|
-
const first = this.#chunks[0];
|
|
27
|
-
if (!first) {
|
|
28
|
-
throw new TypeError("No chunks in composite buffer, cannot infer constructor");
|
|
29
|
-
}
|
|
30
|
-
return first.constructor;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Binary search to find the chunk containing the given index.
|
|
34
|
-
*/
|
|
35
|
-
#findChunkForIndex(index) {
|
|
36
|
-
let left = 0;
|
|
37
|
-
let right = this.#chunkOffsets.length - 1;
|
|
38
|
-
while (left <= right) {
|
|
39
|
-
const mid = Math.floor((left + right) / 2);
|
|
40
|
-
const chunkInfo = this.#chunkOffsets[mid];
|
|
41
|
-
if (index >= chunkInfo.offset && index < chunkInfo.offset + chunkInfo.length) {
|
|
42
|
-
return { chunk: this.#chunks[mid], chunkInfo };
|
|
43
|
-
}
|
|
44
|
-
if (index < chunkInfo.offset) {
|
|
45
|
-
right = mid - 1;
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
left = mid + 1;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Update chunk offset information after modification.
|
|
55
|
-
*/
|
|
56
|
-
#updateChunkOffsets() {
|
|
57
|
-
let currentOffset = 0;
|
|
58
|
-
this.#chunkOffsets = this.#chunks.map((chunk) => {
|
|
59
|
-
const info = { offset: currentOffset, length: chunk.length };
|
|
60
|
-
currentOffset += chunk.length;
|
|
61
|
-
return info;
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
constructor(chunks) {
|
|
65
|
-
if (chunks) {
|
|
66
|
-
this.#chunks = chunks;
|
|
67
|
-
this.#memoizedByteLength = chunks.reduce((sum, chunk) => sum + chunk.length, 0);
|
|
68
|
-
this.#updateChunkOffsets();
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* The combined length of all chunks.
|
|
73
|
-
*
|
|
74
|
-
* @see {@linkcode size} for the number of chunks in the composite buffer.
|
|
75
|
-
*/
|
|
76
|
-
get byteLength() {
|
|
77
|
-
return this.#memoizedByteLength;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* The number of chunks in the composite buffer.
|
|
81
|
-
*
|
|
82
|
-
* @see {@linkcode byteLength} for the total length of the composite buffer.
|
|
83
|
-
*/
|
|
84
|
-
get size() {
|
|
85
|
-
return this.#chunks.length;
|
|
86
|
-
}
|
|
87
|
-
get chunks() {
|
|
88
|
-
return this.#chunks;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* The underlying buffer of the composite buffer.
|
|
92
|
-
*
|
|
93
|
-
* Note that this is not memoized and will create a new buffer each time it is accessed.
|
|
94
|
-
*/
|
|
95
|
-
get buffer() {
|
|
96
|
-
return this.flat();
|
|
97
|
-
}
|
|
98
|
-
get [Symbol.toStringTag]() {
|
|
99
|
-
return "CompositeDataView";
|
|
100
|
-
}
|
|
101
|
-
*[Symbol.iterator]() {
|
|
102
|
-
for (const chunk of this.#chunks) {
|
|
103
|
-
yield* chunk;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Returns the value at the given index, as if the chunks were flattened into a single buffer.
|
|
108
|
-
*/
|
|
109
|
-
at(index) {
|
|
110
|
-
const result = this.#findChunkForIndex(index);
|
|
111
|
-
if (!result) {
|
|
112
|
-
throw new RangeError("Index out of range");
|
|
113
|
-
}
|
|
114
|
-
const { chunk, chunkInfo } = result;
|
|
115
|
-
return chunk[index - chunkInfo.offset];
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Push a chunk onto the composite buffer.
|
|
119
|
-
*/
|
|
120
|
-
append(chunk) {
|
|
121
|
-
this.#chunks.push(chunk);
|
|
122
|
-
this.#memoizedByteLength += chunk.length;
|
|
123
|
-
this.#updateChunkOffsets();
|
|
124
|
-
return this.#memoizedByteLength;
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Prepend a chunk before the first chunk in the composite buffer.
|
|
128
|
-
*
|
|
129
|
-
* @returns The new length of the composite buffer.
|
|
130
|
-
*/
|
|
131
|
-
prepend(chunk) {
|
|
132
|
-
this.#chunks.unshift(chunk);
|
|
133
|
-
this.#memoizedByteLength += chunk.length;
|
|
134
|
-
this.#updateChunkOffsets();
|
|
135
|
-
return this.#memoizedByteLength;
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Remove the most recent chunk from the composite buffer.
|
|
139
|
-
*/
|
|
140
|
-
removeLast() {
|
|
141
|
-
const chunk = this.#chunks.pop();
|
|
142
|
-
if (chunk) {
|
|
143
|
-
this.#memoizedByteLength -= chunk.length;
|
|
144
|
-
this.#updateChunkOffsets();
|
|
145
|
-
}
|
|
146
|
-
return chunk;
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Remove the first chunk from the composite buffer.
|
|
150
|
-
*/
|
|
151
|
-
removeFirst() {
|
|
152
|
-
const chunk = this.#chunks.shift();
|
|
153
|
-
if (chunk) {
|
|
154
|
-
this.#memoizedByteLength -= chunk.length;
|
|
155
|
-
this.#updateChunkOffsets();
|
|
156
|
-
}
|
|
157
|
-
return chunk;
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Returns a view into the underlying chunks without copying data.
|
|
161
|
-
*/
|
|
162
|
-
subarray(
|
|
163
|
-
/**
|
|
164
|
-
* Element to begin at. The offset is inclusive.
|
|
165
|
-
*/
|
|
166
|
-
begin = 0,
|
|
167
|
-
/**
|
|
168
|
-
* Element to end at. The offset is exclusive. If not provided, the view extends to the end of the buffer.
|
|
169
|
-
*/
|
|
170
|
-
end = this.#memoizedByteLength) {
|
|
171
|
-
if (begin < 0) {
|
|
172
|
-
throw new RangeError("Invalid subarray range: begin is negative");
|
|
173
|
-
}
|
|
174
|
-
if (end < 0) {
|
|
175
|
-
throw new RangeError("Invalid subarray range: end is negative");
|
|
176
|
-
}
|
|
177
|
-
// const actualEnd = end === undefined ? this.#memoizedByteLength : end
|
|
178
|
-
const startChunk = this.#findChunkForIndex(begin);
|
|
179
|
-
const endChunk = this.#findChunkForIndex(end - 1);
|
|
180
|
-
if (!startChunk || !endChunk) {
|
|
181
|
-
throw new RangeError("Invalid subarray range: Start: " + begin + ", End: " + end);
|
|
182
|
-
}
|
|
183
|
-
// If the range is within a single chunk, return a view into that chunk
|
|
184
|
-
if (startChunk.chunk === endChunk.chunk) {
|
|
185
|
-
const relativeStart = begin - startChunk.chunkInfo.offset;
|
|
186
|
-
const relativeEnd = end - startChunk.chunkInfo.offset;
|
|
187
|
-
return startChunk.chunk.subarray(relativeStart, relativeEnd);
|
|
188
|
-
}
|
|
189
|
-
// Otherwise, we need to create a new buffer and copy the data
|
|
190
|
-
const Constructor = this.#inferChunkConstructor();
|
|
191
|
-
const length = end - begin;
|
|
192
|
-
const result = new Constructor(length);
|
|
193
|
-
let writeOffset = 0;
|
|
194
|
-
let currentChunkIndex = this.#chunks.indexOf(startChunk.chunk);
|
|
195
|
-
while (currentChunkIndex < this.#chunks.length) {
|
|
196
|
-
const currentChunk = this.#chunks[currentChunkIndex];
|
|
197
|
-
const chunkInfo = this.#chunkOffsets[currentChunkIndex];
|
|
198
|
-
const readStart = currentChunk === startChunk.chunk ? begin - chunkInfo.offset : 0;
|
|
199
|
-
const readEnd = currentChunk === endChunk.chunk ? end - chunkInfo.offset : currentChunk.length;
|
|
200
|
-
result.set(currentChunk.subarray(readStart, readEnd), writeOffset);
|
|
201
|
-
writeOffset += readEnd - readStart;
|
|
202
|
-
if (currentChunk === endChunk.chunk)
|
|
203
|
-
break;
|
|
204
|
-
currentChunkIndex++;
|
|
205
|
-
}
|
|
206
|
-
return result;
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* Flattens the composite buffer into a single buffer.
|
|
210
|
-
*/
|
|
211
|
-
flat() {
|
|
212
|
-
return this.subarray();
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* Returns a shallow copy of the composite buffer.
|
|
216
|
-
*
|
|
217
|
-
* @see {@linkcode subarray} for a view into the underlying chunks.
|
|
218
|
-
*/
|
|
219
|
-
slice(
|
|
220
|
-
/**
|
|
221
|
-
* Zero-based index at which to begin extraction.
|
|
222
|
-
*
|
|
223
|
-
* If this value is negative, it is treated as `byteLength + begin`.
|
|
224
|
-
*/
|
|
225
|
-
start = 0,
|
|
226
|
-
/**
|
|
227
|
-
* Zero-based index before which to end extraction.
|
|
228
|
-
*
|
|
229
|
-
* If this value is negative, it is treated as `byteLength + end`.
|
|
230
|
-
*/
|
|
231
|
-
end = this.#memoizedByteLength) {
|
|
232
|
-
if (start < 0) {
|
|
233
|
-
start = Math.max(0, this.#memoizedByteLength + start);
|
|
234
|
-
}
|
|
235
|
-
if (end < 0) {
|
|
236
|
-
end = Math.max(0, this.#memoizedByteLength + end);
|
|
237
|
-
}
|
|
238
|
-
return this.subarray(start, end);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
//# sourceMappingURL=CompositeDataView.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CompositeDataView.js","sourceRoot":"","sources":["../../lib/CompositeDataView.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAoCH;;GAEG;AACH,MAAM,OAAO,iBAA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E,CAAC;YACb,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,mBAAmB,GAAG,GAAG,CAAC,CAAA;QAClD,CAAC;QAED,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;IACjC,CAAC;CACD"}
|
package/out/lib/IndexQueue.d.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Sister Software
|
|
3
|
-
* @license MIT
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
*/
|
|
6
|
-
import type { ByteRange } from "./shared.js";
|
|
7
|
-
/**
|
|
8
|
-
* A first-in, first-out queue for marking and dequeuing index tuples.
|
|
9
|
-
*/
|
|
10
|
-
export declare class IndexQueue implements IterableIterator<ByteRange> {
|
|
11
|
-
#private;
|
|
12
|
-
/**
|
|
13
|
-
* The number of tuples in the queue.
|
|
14
|
-
*/
|
|
15
|
-
get size(): number;
|
|
16
|
-
/**
|
|
17
|
-
* The total byte length spanned by the tuples in the queue.
|
|
18
|
-
*
|
|
19
|
-
* This is a cached value and may not be accurate if the queue is modified externally.
|
|
20
|
-
*/
|
|
21
|
-
get byteLength(): number;
|
|
22
|
-
/**
|
|
23
|
-
* Append a new tuple to the queue.
|
|
24
|
-
*/
|
|
25
|
-
enqueue(tuple: ByteRange): void;
|
|
26
|
-
/**
|
|
27
|
-
* Get the next tuple in the queue, removing it.
|
|
28
|
-
*/
|
|
29
|
-
dequeue(): ByteRange | undefined;
|
|
30
|
-
/**
|
|
31
|
-
* Peek at the next tuple in the queue without removing it.
|
|
32
|
-
*/
|
|
33
|
-
peek(): ByteRange | undefined;
|
|
34
|
-
/**
|
|
35
|
-
* Peek at the last tuple in the queue without removing it.
|
|
36
|
-
*/
|
|
37
|
-
peekLast(): ByteRange | undefined;
|
|
38
|
-
/**
|
|
39
|
-
* Clear the queue.
|
|
40
|
-
*/
|
|
41
|
-
clear(): void;
|
|
42
|
-
/**
|
|
43
|
-
* Alias for `dequeue`, conforming to the iterator protocol.
|
|
44
|
-
*/
|
|
45
|
-
next(): IteratorResult<ByteRange>;
|
|
46
|
-
[Symbol.iterator](): IndexQueue;
|
|
47
|
-
}
|
|
48
|
-
//# sourceMappingURL=IndexQueue.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IndexQueue.d.ts","sourceRoot":"","sources":["../../lib/IndexQueue.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAS5C;;GAEG;AACH,qBAAa,UAAW,YAAW,gBAAgB,CAAC,SAAS,CAAC;;IAa7D;;OAEG;IACH,IAAW,IAAI,IAAI,MAAM,CAExB;IAID;;;;OAIG;IACH,IAAW,UAAU,IAAI,MAAM,CAE9B;IAED;;OAEG;IACI,OAAO,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAKrC;IAED;;OAEG;IACI,OAAO,IAAI,SAAS,GAAG,SAAS,CAqBtC;IAED;;OAEG;IACI,IAAI,IAAI,SAAS,GAAG,SAAS,CAInC;IAED;;OAEG;IACI,QAAQ,IAAI,SAAS,GAAG,SAAS,CAMvC;IAED;;OAEG;IACI,KAAK,IAAI,IAAI,CAInB;IAED;;OAEG;IACI,IAAI,IAAI,cAAc,CAAC,SAAS,CAAC,CAQvC;IAEM,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,UAAU,CAErC;CACD"}
|
package/out/lib/IndexQueue.js
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Sister Software
|
|
3
|
-
* @license MIT
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Number of consumed slots (`start`/`end` values, i.e. 2 per dequeued tuple) the head pointer may advance before the
|
|
8
|
-
* backing array is compacted. Bounds wasted space under partial draining while keeping compaction rare enough that
|
|
9
|
-
* `dequeue` stays amortized O(1).
|
|
10
|
-
*/
|
|
11
|
-
const COMPACT_THRESHOLD = 1024;
|
|
12
|
-
/**
|
|
13
|
-
* A first-in, first-out queue for marking and dequeuing index tuples.
|
|
14
|
-
*/
|
|
15
|
-
export class IndexQueue {
|
|
16
|
-
/**
|
|
17
|
-
* Flat backing store of `[start, end]` pairs. Consumed entries before `#head` are kept until the queue drains or
|
|
18
|
-
* `#head` crosses {@link COMPACT_THRESHOLD}, so `dequeue` stays O(1) instead of shifting the whole array on every
|
|
19
|
-
* yield.
|
|
20
|
-
*/
|
|
21
|
-
#tuples = [];
|
|
22
|
-
/**
|
|
23
|
-
* Index of the next tuple's `start` in {@link #tuples}; advances by 2 per dequeue.
|
|
24
|
-
*/
|
|
25
|
-
#head = 0;
|
|
26
|
-
/**
|
|
27
|
-
* The number of tuples in the queue.
|
|
28
|
-
*/
|
|
29
|
-
get size() {
|
|
30
|
-
return (this.#tuples.length - this.#head) / 2;
|
|
31
|
-
}
|
|
32
|
-
#byteLength = 0;
|
|
33
|
-
/**
|
|
34
|
-
* The total byte length spanned by the tuples in the queue.
|
|
35
|
-
*
|
|
36
|
-
* This is a cached value and may not be accurate if the queue is modified externally.
|
|
37
|
-
*/
|
|
38
|
-
get byteLength() {
|
|
39
|
-
return this.#byteLength;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Append a new tuple to the queue.
|
|
43
|
-
*/
|
|
44
|
-
enqueue(tuple) {
|
|
45
|
-
this.#tuples.push(tuple[0]);
|
|
46
|
-
this.#tuples.push(tuple[1]);
|
|
47
|
-
this.#byteLength += tuple[1] - tuple[0];
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Get the next tuple in the queue, removing it.
|
|
51
|
-
*/
|
|
52
|
-
dequeue() {
|
|
53
|
-
if (this.#head >= this.#tuples.length)
|
|
54
|
-
return;
|
|
55
|
-
const start = this.#tuples[this.#head];
|
|
56
|
-
const end = this.#tuples[this.#head + 1];
|
|
57
|
-
this.#head += 2;
|
|
58
|
-
this.#byteLength -= end - start;
|
|
59
|
-
// Reclaim consumed space: reset outright once fully drained (the common per-fill pattern
|
|
60
|
-
// in both engines), otherwise compact periodically so the backing array can't grow
|
|
61
|
-
// unbounded when the queue is only partially drained between enqueues.
|
|
62
|
-
if (this.#head >= this.#tuples.length) {
|
|
63
|
-
this.#tuples.length = 0;
|
|
64
|
-
this.#head = 0;
|
|
65
|
-
}
|
|
66
|
-
else if (this.#head >= COMPACT_THRESHOLD) {
|
|
67
|
-
this.#tuples.splice(0, this.#head);
|
|
68
|
-
this.#head = 0;
|
|
69
|
-
}
|
|
70
|
-
return [start, end];
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Peek at the next tuple in the queue without removing it.
|
|
74
|
-
*/
|
|
75
|
-
peek() {
|
|
76
|
-
if (this.#head >= this.#tuples.length)
|
|
77
|
-
return;
|
|
78
|
-
return [this.#tuples[this.#head], this.#tuples[this.#head + 1]];
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Peek at the last tuple in the queue without removing it.
|
|
82
|
-
*/
|
|
83
|
-
peekLast() {
|
|
84
|
-
if (this.#tuples.length - this.#head < 2)
|
|
85
|
-
return;
|
|
86
|
-
const end = this.#tuples.length;
|
|
87
|
-
return [this.#tuples[end - 2], this.#tuples[end - 1]];
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Clear the queue.
|
|
91
|
-
*/
|
|
92
|
-
clear() {
|
|
93
|
-
this.#tuples.length = 0;
|
|
94
|
-
this.#head = 0;
|
|
95
|
-
this.#byteLength = 0;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Alias for `dequeue`, conforming to the iterator protocol.
|
|
99
|
-
*/
|
|
100
|
-
next() {
|
|
101
|
-
const tuple = this.dequeue();
|
|
102
|
-
if (tuple) {
|
|
103
|
-
return { done: false, value: tuple };
|
|
104
|
-
}
|
|
105
|
-
return { done: true, value: undefined };
|
|
106
|
-
}
|
|
107
|
-
[Symbol.iterator]() {
|
|
108
|
-
return this;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
//# sourceMappingURL=IndexQueue.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IndexQueue.js","sourceRoot":"","sources":["../../lib/IndexQueue.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;;GAIG;AACH,MAAM,iBAAiB,GAAG,IAAI,CAAA;AAE9B;;GAEG;AACH,MAAM,OAAO,UAAU;IACtB;;;;OAIG;IACH,OAAO,GAAa,EAAE,CAAA;IAEtB;;OAEG;IACH,KAAK,GAAG,CAAC,CAAA;IAET;;OAEG;IACH,IAAW,IAAI;QACd,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAC9C,CAAC;IAED,WAAW,GAAG,CAAC,CAAA;IAEf;;;;OAIG;IACH,IAAW,UAAU;QACpB,OAAO,IAAI,CAAC,WAAW,CAAA;IACxB,CAAC;IAED;;OAEG;IACI,OAAO,CAAC,KAAgB;QAC9B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;QAC3B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;QAE3B,IAAI,CAAC,WAAW,IAAI,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;IACxC,CAAC;IAED;;OAEG;IACI,OAAO;QACb,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM;YAAE,OAAM;QAE7C,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAE,CAAA;QACvC,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,C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CAAC,CAAA;QACvB,IAAI,CAAC,KAAK,GAAG,CAAC,CAAA;QACd,IAAI,CAAC,WAAW,GAAG,CAAC,CAAA;IACrB,CAAC;IAED;;OAEG;IACI,IAAI;QACV,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,EAAE,CAAA;QAE5B,IAAI,KAAK,EAAE,CAAC;YACX,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,CAAA;QACrC,CAAC;QAED,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,CAAA;IACxC,CAAC;IAEM,CAAC,MAAM,CAAC,QAAQ,CAAC;QACvB,OAAO,IAAI,CAAA;IACZ,CAAC;CACD"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Sister Software
|
|
3
|
-
* @license MIT
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
*/
|
|
6
|
-
import { type AdaptiveSourceInit } from "./adaptive-source.js";
|
|
7
|
-
import { AsyncSequence } from "./AsyncSequence.js";
|
|
8
|
-
import type { CharacterSequenceInput } from "./CharacterSequence.js";
|
|
9
|
-
import type { AsyncDataResource } from "./shared.js";
|
|
10
|
-
import { type SpliteratorInit } from "./Spliterator.js";
|
|
11
|
-
/**
|
|
12
|
-
* Stream a delimited byte source and `JSON.parse` each row — one parsed value per line, for JSONL / NDJSON. The row
|
|
13
|
-
* delimiter defaults to a line feed; override it via `options.delimiter`. `skipEmpty` (on by default) drops blank
|
|
14
|
-
* rows.
|
|
15
|
-
*
|
|
16
|
-
* **Performance caveat — this path is `JSON.parse`-bound, not scan-bound.** Measured over 500k rows (88MB, ~177B per
|
|
17
|
-
* row, Node 26): the delimiter scan is ~140ms and decoding ~46ms, while `JSON.parse` and the per-row async machinery
|
|
18
|
-
* account for the rest of ~1280ms. Against Node's `readline` + `JSON.parse` at ~630ms, this runs **roughly half the
|
|
19
|
-
* speed — a net loss.** Use it for API convenience, or when streaming to bound memory; do NOT swap a working `readline`
|
|
20
|
-
* loop to it expecting a speedup on parse-heavy JSONL.
|
|
21
|
-
*
|
|
22
|
-
* The scan advantage only shows when you _don't_ fully parse every row. Filtering on the raw text and parsing only what
|
|
23
|
-
* survives is the shape that wins — parsing 20% of rows measured ~2.5× faster than parsing all of them:
|
|
24
|
-
*
|
|
25
|
-
* ```ts
|
|
26
|
-
* TextSpliterator.fromAsync(path, { delimiter: "\n" })
|
|
27
|
-
* .filter((line) => line.includes('"category":"Novelty"'))
|
|
28
|
-
* .map((line) => JSON.parse(line))
|
|
29
|
-
* ```
|
|
30
|
-
*
|
|
31
|
-
* For segmentation or counting, use {@link Spliterator} (raw byte ranges) or {@link TextSpliterator}. When unsure,
|
|
32
|
-
* benchmark.
|
|
33
|
-
*/
|
|
34
|
-
export declare abstract class JSONSpliterator {
|
|
35
|
-
constructor();
|
|
36
|
-
static from<T = unknown>(source: CharacterSequenceInput, options?: SpliteratorInit): Generator<T>;
|
|
37
|
-
/**
|
|
38
|
-
* Given a byte array or string, yield each row as an array of columns.
|
|
39
|
-
*
|
|
40
|
-
* @yields Each row as an array of columns.
|
|
41
|
-
*/
|
|
42
|
-
static fromAsync<T = unknown>(source: AsyncDataResource, options?: AdaptiveSourceInit): AsyncSequence<T>;
|
|
43
|
-
}
|
|
44
|
-
//# sourceMappingURL=JSONSpliterator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"JSONSpliterator.d.ts","sourceRoot":"","sources":["../../lib/JSONSpliterator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,kBAAkB,EAAqB,MAAM,sBAAsB,CAAA;AACjF,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AACpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,EAA0C,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAE/F;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,8BAAsB,eAAe;IACpC,cAEC;IAED,MAAM,CAAE,IAAI,CAAC,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,sBAAsB,EAAE,OAAO,GAAE,eAAoB,GAAG,SAAS,CAAC,CAAC,CAAC,CAwBrG;IAED;;;;OAIG;IACH,MAAM,CAAC,SAAS,CAAC,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,OAAO,GAAE,kBAAuB,GAAG,aAAa,CAAC,CAAC,CAAC,CAgB3G;CACD"}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Sister Software
|
|
3
|
-
* @license MIT
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
*/
|
|
6
|
-
import { openDelimitedRows } from "./adaptive-source.js";
|
|
7
|
-
import { AsyncSequence } from "./AsyncSequence.js";
|
|
8
|
-
import { Spliterator } from "./Spliterator.js";
|
|
9
|
-
/**
|
|
10
|
-
* Stream a delimited byte source and `JSON.parse` each row — one parsed value per line, for JSONL / NDJSON. The row
|
|
11
|
-
* delimiter defaults to a line feed; override it via `options.delimiter`. `skipEmpty` (on by default) drops blank
|
|
12
|
-
* rows.
|
|
13
|
-
*
|
|
14
|
-
* **Performance caveat — this path is `JSON.parse`-bound, not scan-bound.** Measured over 500k rows (88MB, ~177B per
|
|
15
|
-
* row, Node 26): the delimiter scan is ~140ms and decoding ~46ms, while `JSON.parse` and the per-row async machinery
|
|
16
|
-
* account for the rest of ~1280ms. Against Node's `readline` + `JSON.parse` at ~630ms, this runs **roughly half the
|
|
17
|
-
* speed — a net loss.** Use it for API convenience, or when streaming to bound memory; do NOT swap a working `readline`
|
|
18
|
-
* loop to it expecting a speedup on parse-heavy JSONL.
|
|
19
|
-
*
|
|
20
|
-
* The scan advantage only shows when you _don't_ fully parse every row. Filtering on the raw text and parsing only what
|
|
21
|
-
* survives is the shape that wins — parsing 20% of rows measured ~2.5× faster than parsing all of them:
|
|
22
|
-
*
|
|
23
|
-
* ```ts
|
|
24
|
-
* TextSpliterator.fromAsync(path, { delimiter: "\n" })
|
|
25
|
-
* .filter((line) => line.includes('"category":"Novelty"'))
|
|
26
|
-
* .map((line) => JSON.parse(line))
|
|
27
|
-
* ```
|
|
28
|
-
*
|
|
29
|
-
* For segmentation or counting, use {@link Spliterator} (raw byte ranges) or {@link TextSpliterator}. When unsure,
|
|
30
|
-
* benchmark.
|
|
31
|
-
*/
|
|
32
|
-
export class JSONSpliterator {
|
|
33
|
-
constructor() {
|
|
34
|
-
throw new TypeError("Static class cannot be instantiated. Did you mean `JSONSpliterator.from`?");
|
|
35
|
-
}
|
|
36
|
-
static *from(source, options = {}) {
|
|
37
|
-
const decoder = new TextDecoder();
|
|
38
|
-
let rowCursor = 0;
|
|
39
|
-
const spliterator = Spliterator.fromSync(source, options);
|
|
40
|
-
for (const row of spliterator) {
|
|
41
|
-
let parsed;
|
|
42
|
-
try {
|
|
43
|
-
const content = decoder.decode(row);
|
|
44
|
-
parsed = JSON.parse(content);
|
|
45
|
-
}
|
|
46
|
-
catch (parsedError) {
|
|
47
|
-
const error = new SyntaxError(`Failed to parse JSON at row ${rowCursor}`);
|
|
48
|
-
error.cause = parsedError;
|
|
49
|
-
throw error;
|
|
50
|
-
}
|
|
51
|
-
yield parsed;
|
|
52
|
-
rowCursor++;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Given a byte array or string, yield each row as an array of columns.
|
|
57
|
-
*
|
|
58
|
-
* @yields Each row as an array of columns.
|
|
59
|
-
*/
|
|
60
|
-
static fromAsync(source, options = {}) {
|
|
61
|
-
const decoder = new TextDecoder();
|
|
62
|
-
// Parsing is an op on the sequence, not a generator wrapped inside one. An allocating row body makes the extra
|
|
63
|
-
// async frame a wrapping generator adds disproportionately expensive: 1460ms against 1278ms over 500k rows, where
|
|
64
|
-
// the same layer costs a third as much when the body only decodes.
|
|
65
|
-
return AsyncSequence.from(() => openDelimitedRows(source, options)).map((row, rowCursor) => {
|
|
66
|
-
try {
|
|
67
|
-
return JSON.parse(decoder.decode(row));
|
|
68
|
-
}
|
|
69
|
-
catch (parsedError) {
|
|
70
|
-
const error = new SyntaxError(`Failed to parse JSON at row ${rowCursor}`);
|
|
71
|
-
error.cause = parsedError;
|
|
72
|
-
throw error;
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
//# sourceMappingURL=JSONSpliterator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"JSONSpliterator.js","sourceRoot":"","sources":["../../lib/JSONSpliterator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAA2B,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AACjF,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAGlD,OAAO,EAA6B,WAAW,EAAwB,MAAM,kBAAkB,CAAA;AAE/F;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,OAAgB,eAAe;IACpC;QACC,MAAM,IAAI,SAAS,CAAC,2EAA2E,CAAC,CAAA;IACjG,CAAC;IAED,MAAM,CAAC,CAAC,IAAI,CAAc,MAA8B,EAAE,OAAO,GAAoB,EAAE;QACtF,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAA;QACjC,IAAI,SAAS,GAAG,CAAC,CAAA;QAEjB,MAAM,WAAW,GAAG,WAAW,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;QAEzD,KAAK,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;YAC/B,IAAI,MAAS,CAAA;YAEb,IAAI,CAAC;gBACJ,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;gBAEnC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAM,CAAA;YAClC,CAAC;YAAC,OAAO,WAAW,EAAE,CAAC;gBACtB,MAAM,KAAK,GAAG,IAAI,WAAW,CAAC,+BAA+B,SAAS,EAAE,CAAC,CAAA;gBACzE,KAAK,CAAC,KAAK,GAAG,WAAW,CAAA;gBAEzB,MAAM,KAAK,CAAA;YACZ,CAAC;YAED,MAAM,MAAM,CAAA;YAEZ,SAAS,EAAE,CAAA;QACZ,CAAC;IACF,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,SAAS,CAAc,MAAyB,EAAE,OAAO,GAAuB,EAAE;QACxF,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAA;QAEjC,+GAA+G;QAC/G,kHAAkH;QAClH,mEAAmE;QACnE,OAAO,aAAa,CAAC,IAAI,CAAa,GAAG,EAAE,CAAC,iBAAiB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,SAAS,EAAE,EAAE;YACtG,IAAI,CAAC;gBACJ,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAM,CAAA;YAC5C,CAAC;YAAC,OAAO,WAAW,EAAE,CAAC;gBACtB,MAAM,KAAK,GAAG,IAAI,WAAW,CAAC,+BAA+B,SAAS,EAAE,CAAC,CAAA;gBACzE,KAAK,CAAC,KAAK,GAAG,WAAW,CAAA;gBAEzB,MAAM,KAAK,CAAA;YACZ,CAAC;QACF,CAAC,CAAC,CAAA;IACH,CAAC;CACD"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Sister Software
|
|
3
|
-
* @license MIT
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
*/
|
|
6
|
-
import { CSVSpliterator } from "./CSVSpliterator.js";
|
|
7
|
-
/**
|
|
8
|
-
* A static class spliterator for pipe-separated values.
|
|
9
|
-
*
|
|
10
|
-
* @see {@linkcode PSVSpliterator.from} for synchronous usage.
|
|
11
|
-
* @see {@linkcode PSVSpliterator.fromAsync} for asynchronous usage.
|
|
12
|
-
*/
|
|
13
|
-
export declare abstract class PSVSpliterator extends CSVSpliterator {
|
|
14
|
-
/**
|
|
15
|
-
* The column delimiter used by the spliterator.
|
|
16
|
-
*
|
|
17
|
-
* @default Delimiters.Pipe
|
|
18
|
-
*/
|
|
19
|
-
static ColumnDelimiter: number;
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=PSVSpliterator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PSVSpliterator.d.ts","sourceRoot":"","sources":["../../lib/PSVSpliterator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAEpD;;;;;GAKG;AACH,8BAAsB,cAAe,SAAQ,cAAc;IAC1D;;;;OAIG;IACH,OAAuB,eAAe,EAAE,MAAM,CAAkB;CAChE"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Sister Software
|
|
3
|
-
* @license MIT
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
*/
|
|
6
|
-
import { Delimiters } from "./CharacterSequence.js";
|
|
7
|
-
import { CSVSpliterator } from "./CSVSpliterator.js";
|
|
8
|
-
/**
|
|
9
|
-
* A static class spliterator for pipe-separated values.
|
|
10
|
-
*
|
|
11
|
-
* @see {@linkcode PSVSpliterator.from} for synchronous usage.
|
|
12
|
-
* @see {@linkcode PSVSpliterator.fromAsync} for asynchronous usage.
|
|
13
|
-
*/
|
|
14
|
-
export class PSVSpliterator extends CSVSpliterator {
|
|
15
|
-
/**
|
|
16
|
-
* The column delimiter used by the spliterator.
|
|
17
|
-
*
|
|
18
|
-
* @default Delimiters.Pipe
|
|
19
|
-
*/
|
|
20
|
-
static ColumnDelimiter = Delimiters.Pipe;
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=PSVSpliterator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PSVSpliterator.js","sourceRoot":"","sources":["../../lib/PSVSpliterator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAEpD;;;;;GAKG;AACH,MAAM,OAAgB,cAAe,SAAQ,cAAc;IAC1D;;;;OAIG;IACI,MAAM,CAAU,eAAe,GAAW,UAAU,CAAC,IAAI,CAAA;CAChE"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Sister Software
|
|
3
|
-
* @license MIT
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
*/
|
|
6
|
-
import { type CharacterSequenceInput } from "./CharacterSequence.js";
|
|
7
|
-
import type { ByteRange, TypedArray } from "./shared.js";
|
|
8
|
-
export interface SlidingWindowInit {
|
|
9
|
-
/**
|
|
10
|
-
* The delimiter to use. Defaults to a line feed.
|
|
11
|
-
*/
|
|
12
|
-
delimiter?: CharacterSequenceInput;
|
|
13
|
-
/**
|
|
14
|
-
* The byte index to start searching from.
|
|
15
|
-
*/
|
|
16
|
-
position?: number;
|
|
17
|
-
/**
|
|
18
|
-
* The byte index to stop searching at.
|
|
19
|
-
*/
|
|
20
|
-
byteLength?: number;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* A sliding window that iterates over an in-memory buffer, yielding byte ranges.
|
|
24
|
-
*
|
|
25
|
-
* @see {@link AsyncSlidingWindow} for an asynchronous version.
|
|
26
|
-
*/
|
|
27
|
-
export declare class SlidingWindow<T extends TypedArray> implements IterableIterator<ByteRange> {
|
|
28
|
-
#private;
|
|
29
|
-
buffer: T;
|
|
30
|
-
/**
|
|
31
|
-
* The current byte index of the sliding window.
|
|
32
|
-
*/
|
|
33
|
-
cursor: number;
|
|
34
|
-
/**
|
|
35
|
-
* Given a byte array containing delimited data, yield a sliding window of indexes.
|
|
36
|
-
*
|
|
37
|
-
* This a low-level utility function that can be used to implement more complex parsing logic.
|
|
38
|
-
*/
|
|
39
|
-
constructor(
|
|
40
|
-
/**
|
|
41
|
-
* The buffer containing delimited data.
|
|
42
|
-
*/
|
|
43
|
-
buffer: T, init?: SlidingWindowInit);
|
|
44
|
-
next(): IteratorResult<ByteRange>;
|
|
45
|
-
[Symbol.iterator](): IterableIterator<ByteRange>;
|
|
46
|
-
}
|
|
47
|
-
//# sourceMappingURL=SlidingWindow.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SlidingWindow.d.ts","sourceRoot":"","sources":["../../lib/SlidingWindow.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAqB,KAAK,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AACvF,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExD,MAAM,WAAW,iBAAiB;IACjC;;OAEG;IACH,SAAS,CAAC,EAAE,sBAAsB,CAAA;IAElC;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IAEjB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;;;GAIG;AACH,qBAAa,aAAa,CAAC,CAAC,SAAS,UAAU,CAAE,YAAW,gBAAgB,CAAC,SAAS,CAAC;;IACtF,MAAM,EAAE,CAAC,CAAA;IAKT;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IAEd;;;;OAIG;IACH;IACC;;OAEG;IACH,MAAM,EAAE,CAAC,EACT,IAAI,GAAE,iBAAsB,EAM5B;IAEM,IAAI,IAAI,cAAc,CAAC,SAAS,CAAC,CA6BvC;IAEM,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,gBAAgB,CAAC,SAAS,CAAC,CAEtD;CACD"}
|