spliterator 1.5.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/LICENSE.md +650 -0
- package/README.md +119 -0
- package/out/index.d.ts +21 -0
- package/out/index.d.ts.map +1 -0
- package/out/index.js +21 -0
- package/out/index.js.map +1 -0
- package/out/lib/AsyncSpliterator.d.ts +127 -0
- package/out/lib/AsyncSpliterator.d.ts.map +1 -0
- package/out/lib/AsyncSpliterator.js +332 -0
- package/out/lib/AsyncSpliterator.js.map +1 -0
- package/out/lib/BufferController.d.ts +62 -0
- package/out/lib/BufferController.d.ts.map +1 -0
- package/out/lib/BufferController.js +93 -0
- package/out/lib/BufferController.js.map +1 -0
- package/out/lib/CSVSpliterator.d.ts +104 -0
- package/out/lib/CSVSpliterator.d.ts.map +1 -0
- package/out/lib/CSVSpliterator.js +83 -0
- package/out/lib/CSVSpliterator.js.map +1 -0
- package/out/lib/CharacterSequence.d.ts +103 -0
- package/out/lib/CharacterSequence.d.ts.map +1 -0
- package/out/lib/CharacterSequence.js +184 -0
- package/out/lib/CharacterSequence.js.map +1 -0
- package/out/lib/CompositeDataView.d.ts +104 -0
- package/out/lib/CompositeDataView.d.ts.map +1 -0
- package/out/lib/CompositeDataView.js +242 -0
- package/out/lib/CompositeDataView.js.map +1 -0
- package/out/lib/DelimitedChunkReader.d.ts +67 -0
- package/out/lib/DelimitedChunkReader.d.ts.map +1 -0
- package/out/lib/DelimitedChunkReader.js +113 -0
- package/out/lib/DelimitedChunkReader.js.map +1 -0
- package/out/lib/DelimiterTransformer.d.ts +27 -0
- package/out/lib/DelimiterTransformer.d.ts.map +1 -0
- package/out/lib/DelimiterTransformer.js +26 -0
- package/out/lib/DelimiterTransformer.js.map +1 -0
- package/out/lib/IndexQueue.d.ts +48 -0
- package/out/lib/IndexQueue.d.ts.map +1 -0
- package/out/lib/IndexQueue.js +80 -0
- package/out/lib/IndexQueue.js.map +1 -0
- package/out/lib/JSONSpliterator.d.ts +19 -0
- package/out/lib/JSONSpliterator.d.ts.map +1 -0
- package/out/lib/JSONSpliterator.js +55 -0
- package/out/lib/JSONSpliterator.js.map +1 -0
- package/out/lib/SlidingWindow.d.ts +93 -0
- package/out/lib/SlidingWindow.d.ts.map +1 -0
- package/out/lib/SlidingWindow.js +176 -0
- package/out/lib/SlidingWindow.js.map +1 -0
- package/out/lib/Spliterator.d.ts +51 -0
- package/out/lib/Spliterator.d.ts.map +1 -0
- package/out/lib/Spliterator.js +238 -0
- package/out/lib/Spliterator.js.map +1 -0
- package/out/lib/TextSpliterator.d.ts +40 -0
- package/out/lib/TextSpliterator.d.ts.map +1 -0
- package/out/lib/TextSpliterator.js +56 -0
- package/out/lib/TextSpliterator.js.map +1 -0
- package/out/lib/casing.d.ts +28 -0
- package/out/lib/casing.d.ts.map +1 -0
- package/out/lib/casing.js +69 -0
- package/out/lib/casing.js.map +1 -0
- package/out/lib/node/fs.d.ts +98 -0
- package/out/lib/node/fs.d.ts.map +1 -0
- package/out/lib/node/fs.js +162 -0
- package/out/lib/node/fs.js.map +1 -0
- package/out/lib/shared.d.ts +167 -0
- package/out/lib/shared.d.ts.map +1 -0
- package/out/lib/shared.js +92 -0
- package/out/lib/shared.js.map +1 -0
- package/out/lib/take.d.ts +26 -0
- package/out/lib/take.d.ts.map +1 -0
- package/out/lib/take.js +71 -0
- package/out/lib/take.js.map +1 -0
- package/out/lib/writer.d.ts +34 -0
- package/out/lib/writer.d.ts.map +1 -0
- package/out/lib/writer.js +41 -0
- package/out/lib/writer.js.map +1 -0
- package/package.json +100 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* A first-in, first-out queue for marking and dequeuing index tuples.
|
|
8
|
+
*/
|
|
9
|
+
export class IndexQueue {
|
|
10
|
+
#tuples = [];
|
|
11
|
+
/**
|
|
12
|
+
* The number of tuples in the queue.
|
|
13
|
+
*/
|
|
14
|
+
get size() {
|
|
15
|
+
return this.#tuples.length / 2;
|
|
16
|
+
}
|
|
17
|
+
#byteLength = 0;
|
|
18
|
+
/**
|
|
19
|
+
* The total byte length spanned by the tuples in the queue.
|
|
20
|
+
*
|
|
21
|
+
* This is a cached value and may not be accurate if the queue is modified externally.
|
|
22
|
+
*/
|
|
23
|
+
get byteLength() {
|
|
24
|
+
return this.#byteLength;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Append a new tuple to the queue.
|
|
28
|
+
*/
|
|
29
|
+
enqueue(tuple) {
|
|
30
|
+
this.#tuples.push(...tuple);
|
|
31
|
+
this.#byteLength += tuple[1] - tuple[0];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Get the next tuple in the queue, removing it.
|
|
35
|
+
*/
|
|
36
|
+
dequeue() {
|
|
37
|
+
if (this.#tuples.length < 2)
|
|
38
|
+
return;
|
|
39
|
+
const tuple = this.#tuples.splice(0, 2);
|
|
40
|
+
this.#byteLength -= tuple[1] - tuple[0];
|
|
41
|
+
return tuple;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Peek at the next tuple in the queue without removing it.
|
|
45
|
+
*/
|
|
46
|
+
peek() {
|
|
47
|
+
if (this.#tuples.length < 2)
|
|
48
|
+
return;
|
|
49
|
+
return this.#tuples.slice(0, 2);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Peek at the last tuple in the queue without removing it.
|
|
53
|
+
*/
|
|
54
|
+
peekLast() {
|
|
55
|
+
if (this.#tuples.length < 2)
|
|
56
|
+
return;
|
|
57
|
+
return this.#tuples.slice(-2);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Clear the queue.
|
|
61
|
+
*/
|
|
62
|
+
clear() {
|
|
63
|
+
this.#tuples.length = 0;
|
|
64
|
+
this.#byteLength = 0;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Alias for `dequeue`, conforming to the iterator protocol.
|
|
68
|
+
*/
|
|
69
|
+
next() {
|
|
70
|
+
const tuple = this.dequeue();
|
|
71
|
+
if (tuple) {
|
|
72
|
+
return { done: false, value: tuple };
|
|
73
|
+
}
|
|
74
|
+
return { done: true, value: undefined };
|
|
75
|
+
}
|
|
76
|
+
[Symbol.iterator]() {
|
|
77
|
+
return this;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=IndexQueue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IndexQueue.js","sourceRoot":"","sources":["../../lib/IndexQueue.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;GAEG;AACH,MAAM,OAAO,UAAU;IACtB,OAAO,GAAa,EAAE,CAAA;IAEtB;;OAEG;IACH,IAAW,IAAI;QACd,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAA;IAC/B,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,GAAG,KAAK,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,OAAO,CAAC,MAAM,GAAG,CAAC;YAAE,OAAM;QAEnC,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAc,CAAA;QAEpD,IAAI,CAAC,WAAW,IAAI,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;QAEvC,OAAO,KAAkB,CAAA;IAC1B,CAAC;IAED;;OAEG;IACI,IAAI;QACV,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC;YAAE,OAAM;QAEnC,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAc,CAAA;IAC7C,CAAC;IAED;;OAEG;IACI,QAAQ;QACd,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC;YAAE,OAAM;QAEnC,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAc,CAAA;IAC3C,CAAC;IAED;;OAEG;IACI,KAAK;QACX,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAA;QACvB,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"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
import { CharacterSequenceInput } from "./CharacterSequence.js";
|
|
7
|
+
import { AsyncDataResource } from "./shared.js";
|
|
8
|
+
import { AsyncSpliteratorInit, SpliteratorInit } from "./Spliterator.js";
|
|
9
|
+
export declare abstract class JSONSpliterator {
|
|
10
|
+
constructor();
|
|
11
|
+
static from<T = unknown>(source: CharacterSequenceInput, options?: SpliteratorInit): Generator<T>;
|
|
12
|
+
/**
|
|
13
|
+
* Given a byte array or string, yield each row as an array of columns.
|
|
14
|
+
*
|
|
15
|
+
* @yields Each row as an array of columns.
|
|
16
|
+
*/
|
|
17
|
+
static fromAsync<T = unknown>(source: AsyncDataResource, options?: AsyncSpliteratorInit): AsyncGenerator<Awaited<T>, void, unknown>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=JSONSpliterator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JSONSpliterator.d.ts","sourceRoot":"","sources":["../../lib/JSONSpliterator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAAE,oBAAoB,EAAe,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAErF,8BAAsB,eAAe;;IAKpC,MAAM,CAAE,IAAI,CAAC,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,sBAAsB,EAAE,OAAO,GAAE,eAAoB,GAAG,SAAS,CAAC,CAAC,CAAC;IA0BtG;;;;OAIG;WACW,SAAS,CAAC,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,OAAO,GAAE,oBAAyB;CAwBlG"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
import { Spliterator } from "./Spliterator.js";
|
|
7
|
+
export class JSONSpliterator {
|
|
8
|
+
constructor() {
|
|
9
|
+
throw new TypeError("Static class cannot be instantiated. Did you mean `JSONSpliterator.from`?");
|
|
10
|
+
}
|
|
11
|
+
static *from(source, options = {}) {
|
|
12
|
+
const decoder = new TextDecoder();
|
|
13
|
+
let rowCursor = 0;
|
|
14
|
+
const spliterator = Spliterator.from(source, options);
|
|
15
|
+
for (const row of spliterator) {
|
|
16
|
+
let parsed;
|
|
17
|
+
try {
|
|
18
|
+
const content = decoder.decode(row);
|
|
19
|
+
parsed = JSON.parse(content);
|
|
20
|
+
}
|
|
21
|
+
catch (parsedError) {
|
|
22
|
+
const error = SyntaxError(`Failed to parse JSON at row ${rowCursor}`);
|
|
23
|
+
error.cause = parsedError;
|
|
24
|
+
throw error;
|
|
25
|
+
}
|
|
26
|
+
yield parsed;
|
|
27
|
+
rowCursor++;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Given a byte array or string, yield each row as an array of columns.
|
|
32
|
+
*
|
|
33
|
+
* @yields Each row as an array of columns.
|
|
34
|
+
*/
|
|
35
|
+
static async *fromAsync(source, options = {}) {
|
|
36
|
+
const decoder = new TextDecoder();
|
|
37
|
+
let rowCursor = 0;
|
|
38
|
+
const spliterator = await Spliterator.fromAsync(source, options);
|
|
39
|
+
for await (const row of spliterator) {
|
|
40
|
+
let parsed;
|
|
41
|
+
try {
|
|
42
|
+
const content = decoder.decode(row);
|
|
43
|
+
parsed = JSON.parse(content);
|
|
44
|
+
}
|
|
45
|
+
catch (parsedError) {
|
|
46
|
+
const error = SyntaxError(`Failed to parse JSON at row ${rowCursor}`);
|
|
47
|
+
error.cause = parsedError;
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
yield parsed;
|
|
51
|
+
rowCursor++;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=JSONSpliterator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JSONSpliterator.js","sourceRoot":"","sources":["../../lib/JSONSpliterator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAwB,WAAW,EAAmB,MAAM,kBAAkB,CAAA;AAErF,MAAM,OAAgB,eAAe;IACpC;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KAAK,CAAC,OAAO,CAAM,CAAA;YAClC,CAAC;YAAC,OAAO,WAAW,EAAE,CAAC;gBACtB,MAAM,KAAK,GAAG,WAAW,CAAC,+BAA+B,SAAS,EAAE,CAAC,CAAA;gBACrE,KAAK,CAAC,KAAK,GAAG,WAAW,CAAA;gBAEzB,MAAM,KAAK,CAAA;YACZ,CAAC;YAED,MAAM,MAAM,CAAA;YAEZ,SAAS,EAAE,CAAA;QACZ,CAAC;IACF,CAAC;CACD"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
import { CharacterSequenceInput } from "./CharacterSequence.js";
|
|
7
|
+
import { ByteRange, FileResourceLike, 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
|
+
/**
|
|
48
|
+
* Options for initializing an asynchronous sliding window.
|
|
49
|
+
*/
|
|
50
|
+
export interface AsyncSlidingWindowInit extends SlidingWindowInit {
|
|
51
|
+
/**
|
|
52
|
+
* Whether to close the file handle when the iterator is completed or disposed.
|
|
53
|
+
*/
|
|
54
|
+
autoClose?: boolean;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* An asynchronous sliding window that iterates over a file handle, yielding byte ranges.
|
|
58
|
+
*
|
|
59
|
+
* @see {@link SlidingWindow} for a synchronous version.
|
|
60
|
+
*/
|
|
61
|
+
export declare class AsyncSlidingWindow implements AsyncIterableIterator<ByteRange>, AsyncDisposable {
|
|
62
|
+
#private;
|
|
63
|
+
/**
|
|
64
|
+
* The current byte index of the sliding window.
|
|
65
|
+
*/
|
|
66
|
+
cursor: number;
|
|
67
|
+
/**
|
|
68
|
+
* Given a byte array containing delimited data, yield a sliding window of indexes.
|
|
69
|
+
*
|
|
70
|
+
* This a low-level utility function that can be used to implement more complex parsing logic.
|
|
71
|
+
*/
|
|
72
|
+
constructor(file: FileResourceLike, init: AsyncSlidingWindowInit);
|
|
73
|
+
/**
|
|
74
|
+
* Read the next byte range from the file handle.
|
|
75
|
+
*/
|
|
76
|
+
next(): Promise<IteratorResult<ByteRange>>;
|
|
77
|
+
/**
|
|
78
|
+
* Read the previous byte range from the file handle.
|
|
79
|
+
*
|
|
80
|
+
* This is useful for backtracking in the event that a delimiter is split across two windows.
|
|
81
|
+
*/
|
|
82
|
+
previous(): Promise<IteratorResult<ByteRange>>;
|
|
83
|
+
/**
|
|
84
|
+
* Given a collection of sliding windows, iterate over them and coalesce adjacent windows.
|
|
85
|
+
*
|
|
86
|
+
* @yields Each coalesced window.
|
|
87
|
+
*/
|
|
88
|
+
static collect(slidingWindows: AsyncSlidingWindow[]): AsyncGenerator<ByteRange[]>;
|
|
89
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
90
|
+
dispose(): Promise<void>;
|
|
91
|
+
[Symbol.asyncIterator](): AsyncIterableIterator<ByteRange>;
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=SlidingWindow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SlidingWindow.d.ts","sourceRoot":"","sources":["../../lib/SlidingWindow.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAqB,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AAClF,OAAO,EAAuB,SAAS,EAAmB,gBAAgB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE3G,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;;IAEF;;OAEG;IACH,MAAM,EAAE,CAAC,EACT,IAAI,GAAE,iBAAsB;IAQtB,IAAI,IAAI,cAAc,CAAC,SAAS,CAAC;IA8BjC,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,gBAAgB,CAAC,SAAS,CAAC;CAGvD;AAED;;GAEG;AACH,MAAM,WAAW,sBAAuB,SAAQ,iBAAiB;IAChE;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;CACnB;AAED;;;;GAIG;AACH,qBAAa,kBAAmB,YAAW,qBAAqB,CAAC,SAAS,CAAC,EAAE,eAAe;;IAO3F;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IAEd;;;;OAIG;gBACS,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,sBAAsB;IAUhE;;OAEG;IACU,IAAI,IAAI,OAAO,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;IAqCvD;;;;OAIG;IACU,QAAQ,IAAI,OAAO,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;IAuB3D;;;;OAIG;WACW,OAAO,CAAC,cAAc,EAAE,kBAAkB,EAAE,GAAG,cAAc,CAAC,SAAS,EAAE,CAAC;IAyB3E,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC;IAM5C,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAIxB,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,qBAAqB,CAAC,SAAS,CAAC;CAGjE"}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
import { CharacterSequence } from "./CharacterSequence.js";
|
|
7
|
+
import { applyReaderPolyfill } from "./shared.js";
|
|
8
|
+
/**
|
|
9
|
+
* A sliding window that iterates over an in-memory buffer, yielding byte ranges.
|
|
10
|
+
*
|
|
11
|
+
* @see {@link AsyncSlidingWindow} for an asynchronous version.
|
|
12
|
+
*/
|
|
13
|
+
export class SlidingWindow {
|
|
14
|
+
buffer;
|
|
15
|
+
#delimiter;
|
|
16
|
+
#byteLength;
|
|
17
|
+
#done = false;
|
|
18
|
+
/**
|
|
19
|
+
* The current byte index of the sliding window.
|
|
20
|
+
*/
|
|
21
|
+
cursor;
|
|
22
|
+
/**
|
|
23
|
+
* Given a byte array containing delimited data, yield a sliding window of indexes.
|
|
24
|
+
*
|
|
25
|
+
* This a low-level utility function that can be used to implement more complex parsing logic.
|
|
26
|
+
*/
|
|
27
|
+
constructor(
|
|
28
|
+
/**
|
|
29
|
+
* The buffer containing delimited data.
|
|
30
|
+
*/
|
|
31
|
+
buffer, init = {}) {
|
|
32
|
+
this.buffer = buffer;
|
|
33
|
+
this.#delimiter = new CharacterSequence(init.delimiter);
|
|
34
|
+
this.cursor = init.position ?? 0;
|
|
35
|
+
this.#byteLength = Math.min(init.byteLength ?? buffer.byteLength, buffer.byteLength);
|
|
36
|
+
}
|
|
37
|
+
next() {
|
|
38
|
+
for (let end = this.cursor; end < this.#byteLength; end++) {
|
|
39
|
+
// We walk through as many bytes as the delimiter has...
|
|
40
|
+
const match = this.#delimiter.every((byte, i) => byte === this.buffer[end + i]);
|
|
41
|
+
// We didn't find a match, so we continue.
|
|
42
|
+
if (!match)
|
|
43
|
+
continue;
|
|
44
|
+
const range = [this.cursor, end];
|
|
45
|
+
this.cursor = end + this.#delimiter.length;
|
|
46
|
+
return { value: range, done: false };
|
|
47
|
+
}
|
|
48
|
+
if (this.cursor <= this.#byteLength && !this.#done) {
|
|
49
|
+
const range = [this.cursor, this.#byteLength];
|
|
50
|
+
this.cursor = this.#byteLength;
|
|
51
|
+
this.#done = true;
|
|
52
|
+
return { value: range, done: false };
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
value: undefined,
|
|
56
|
+
done: true,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
[Symbol.iterator]() {
|
|
60
|
+
return this;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* An asynchronous sliding window that iterates over a file handle, yielding byte ranges.
|
|
65
|
+
*
|
|
66
|
+
* @see {@link SlidingWindow} for a synchronous version.
|
|
67
|
+
*/
|
|
68
|
+
export class AsyncSlidingWindow {
|
|
69
|
+
#file;
|
|
70
|
+
#delimiter;
|
|
71
|
+
#byteLength;
|
|
72
|
+
#done = false;
|
|
73
|
+
#autoClose;
|
|
74
|
+
/**
|
|
75
|
+
* The current byte index of the sliding window.
|
|
76
|
+
*/
|
|
77
|
+
cursor;
|
|
78
|
+
/**
|
|
79
|
+
* Given a byte array containing delimited data, yield a sliding window of indexes.
|
|
80
|
+
*
|
|
81
|
+
* This a low-level utility function that can be used to implement more complex parsing logic.
|
|
82
|
+
*/
|
|
83
|
+
constructor(file, init) {
|
|
84
|
+
applyReaderPolyfill(file);
|
|
85
|
+
this.#file = file;
|
|
86
|
+
this.#byteLength = init.byteLength ?? Infinity;
|
|
87
|
+
this.#delimiter = new CharacterSequence(init.delimiter);
|
|
88
|
+
this.cursor = init.position ?? 0;
|
|
89
|
+
this.#autoClose = init.autoClose ?? false;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Read the next byte range from the file handle.
|
|
93
|
+
*/
|
|
94
|
+
async next() {
|
|
95
|
+
const lookahead = this.#delimiter.length;
|
|
96
|
+
for (let end = this.cursor; end < this.#byteLength; end++) {
|
|
97
|
+
const byteSlice = await this.#file.read({
|
|
98
|
+
position: end,
|
|
99
|
+
// lenegth: end + lookahead
|
|
100
|
+
});
|
|
101
|
+
const match = byteSlice.every((byte, i) => byte === this.#delimiter[i]);
|
|
102
|
+
if (!match)
|
|
103
|
+
continue;
|
|
104
|
+
const range = [this.cursor, end];
|
|
105
|
+
this.cursor = end + lookahead;
|
|
106
|
+
return { value: range, done: false };
|
|
107
|
+
}
|
|
108
|
+
// Handle the final window if we haven't reached the byte limit
|
|
109
|
+
// and there's remaining content after the last delimiter
|
|
110
|
+
if (this.cursor <= this.#byteLength && !this.#done) {
|
|
111
|
+
const range = [this.cursor, this.#byteLength];
|
|
112
|
+
this.cursor = this.#byteLength;
|
|
113
|
+
this.#done = true;
|
|
114
|
+
return { value: range, done: false };
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
value: undefined,
|
|
118
|
+
done: true,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Read the previous byte range from the file handle.
|
|
123
|
+
*
|
|
124
|
+
* This is useful for backtracking in the event that a delimiter is split across two windows.
|
|
125
|
+
*/
|
|
126
|
+
async previous() {
|
|
127
|
+
const lookahead = this.#delimiter.length;
|
|
128
|
+
for (let start = this.cursor; start > 0; start--) {
|
|
129
|
+
const byteSlice = await this.#file.read({ position: start - lookahead, length: start });
|
|
130
|
+
const match = byteSlice.every((byte, i) => byte === this.#delimiter[i]);
|
|
131
|
+
if (!match)
|
|
132
|
+
continue;
|
|
133
|
+
const range = [start - lookahead, this.cursor];
|
|
134
|
+
this.cursor = start - lookahead;
|
|
135
|
+
return { value: range, done: false };
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
138
|
+
value: undefined,
|
|
139
|
+
done: true,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Given a collection of sliding windows, iterate over them and coalesce adjacent windows.
|
|
144
|
+
*
|
|
145
|
+
* @yields Each coalesced window.
|
|
146
|
+
*/
|
|
147
|
+
static async *collect(slidingWindows) {
|
|
148
|
+
let results;
|
|
149
|
+
let done;
|
|
150
|
+
do {
|
|
151
|
+
results = await Promise.all(slidingWindows.map((window) => {
|
|
152
|
+
return window.next();
|
|
153
|
+
}));
|
|
154
|
+
const emitted = [];
|
|
155
|
+
for (const result of results) {
|
|
156
|
+
done = result.done;
|
|
157
|
+
if (result.done)
|
|
158
|
+
continue;
|
|
159
|
+
emitted.push(result.value);
|
|
160
|
+
}
|
|
161
|
+
yield emitted;
|
|
162
|
+
} while (!done);
|
|
163
|
+
}
|
|
164
|
+
async [Symbol.asyncDispose]() {
|
|
165
|
+
if (this.#autoClose) {
|
|
166
|
+
await this.#file[Symbol.asyncDispose]?.();
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
dispose() {
|
|
170
|
+
return this[Symbol.asyncDispose]();
|
|
171
|
+
}
|
|
172
|
+
[Symbol.asyncIterator]() {
|
|
173
|
+
return this;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=SlidingWindow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SlidingWindow.js","sourceRoot":"","sources":["../../lib/SlidingWindow.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,iBAAiB,EAA0B,MAAM,wBAAwB,CAAA;AAClF,OAAO,EAAE,mBAAmB,EAA4D,MAAM,aAAa,CAAA;AAmB3G;;;;GAIG;AACH,MAAM,OAAO,aAAa;IACzB,MAAM,CAAG;IACT,UAAU,CAAmB;IAC7B,WAAW,CAAQ;IACnB,KAAK,GAAG,KAAK,CAAA;IAEb;;OAEG;IACH,MAAM,CAAQ;IAEd;;;;OAIG;IACH;IACC;;OAEG;IACH,MAAS,EACT,OAA0B,EAAE;QAE5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,UAAU,GAAG,IAAI,iBAAiB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;QACvD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,QAAQ,IAAI,CAAC,CAAA;QAChC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,IAAI,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC,CAAA;IACrF,CAAC;IAEM,IAAI;QACV,KAAK,IAAI,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,IAAI,CAAC,WAAW,EAAE,GAAG,EAAE,EAAE,CAAC;YAC3D,wDAAwD;YACxD,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,KAAK,IAAI,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAA;YAE/E,0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EAAE;gBAC7B,OAAO,MAAM,CAAC,IAAI,EAAE,CAAA;YACrB,CAAC,CAAC,CACF,CAAA;YAED,MAAM,OAAO,GAAgB,EAAE,CAAA;YAE/B,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;gBAC9B,IAAI,GAAG,MAAM,CAAC,IAAI,CAAA;gBAElB,IAAI,MAAM,CAAC,IAAI;oBAAE,SAAQ;gBAEzB,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;YAC3B,CAAC;YAED,MAAM,OAAO,CAAA;QACd,CAAC,QAAQ,CAAC,IAAI,EAAC;IAChB,CAAC;IAEM,KAAK,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC;QACjC,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACrB,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,EAAE,CAAA;QAC1C,CAAC;IACF,CAAC;IAEM,OAAO;QACb,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,CAAA;IACnC,CAAC;IAEM,CAAC,MAAM,CAAC,aAAa,CAAC;QAC5B,OAAO,IAAI,CAAA;IACZ,CAAC;CACD"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
import { AsyncSpliterator, AsyncSpliteratorInit, SpliteratorInit } from "./AsyncSpliterator.js";
|
|
7
|
+
import { CharacterSequenceInput } from "./CharacterSequence.js";
|
|
8
|
+
export { AsyncSpliterator };
|
|
9
|
+
export type { AsyncSpliteratorInit, SpliteratorInit };
|
|
10
|
+
/**
|
|
11
|
+
* A byte stream delimiting iterator.
|
|
12
|
+
*/
|
|
13
|
+
export declare class Spliterator implements IterableIterator<Uint8Array>, Disposable {
|
|
14
|
+
#private;
|
|
15
|
+
/**
|
|
16
|
+
* Create a spliterator from an asynchronous resource such as a file.
|
|
17
|
+
*
|
|
18
|
+
* This is an alias for `AsyncSpliterator.from`.
|
|
19
|
+
*
|
|
20
|
+
* @param source - The data resource to read from.
|
|
21
|
+
* @param init - The initialization options for the generator.
|
|
22
|
+
* @see {@linkcode AsyncSpliterator} for usage.
|
|
23
|
+
*/
|
|
24
|
+
static fromAsync: typeof AsyncSpliterator.from;
|
|
25
|
+
/**
|
|
26
|
+
* Create a spliterator from an iterable resource such as a buffer, array, or string.
|
|
27
|
+
*
|
|
28
|
+
* @param source - The data resource to read from.
|
|
29
|
+
* @param init - The initialization options for the generator.
|
|
30
|
+
*/
|
|
31
|
+
static from<T extends CharacterSequenceInput>(source: T, init?: SpliteratorInit): Spliterator;
|
|
32
|
+
/**
|
|
33
|
+
* Dispose of the spliterator, closing the file handle if necessary.
|
|
34
|
+
*/
|
|
35
|
+
[Symbol.dispose](): void;
|
|
36
|
+
constructor(source: Uint8Array, init?: SpliteratorInit);
|
|
37
|
+
/**
|
|
38
|
+
* Read the next byte range from the source.
|
|
39
|
+
*/
|
|
40
|
+
next(): IteratorResult<Uint8Array>;
|
|
41
|
+
/**
|
|
42
|
+
* Collect all the byte ranges from the file.
|
|
43
|
+
*/
|
|
44
|
+
toArray(): Uint8Array[];
|
|
45
|
+
/**
|
|
46
|
+
* Collect all the byte ranges from the file as a string.
|
|
47
|
+
*/
|
|
48
|
+
toDecodedArray(decoder?: import("util").TextDecoder): string[];
|
|
49
|
+
[Symbol.iterator](): IterableIterator<Uint8Array>;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=Spliterator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Spliterator.d.ts","sourceRoot":"","sources":["../../lib/Spliterator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAC/F,OAAO,EAAqB,sBAAsB,EAA2B,MAAM,wBAAwB,CAAA;AAI3G,OAAO,EAAE,gBAAgB,EAAE,CAAA;AAE3B,YAAY,EAAE,oBAAoB,EAAE,eAAe,EAAE,CAAA;AAErD;;GAEG;AACH,qBAAa,WAAY,YAAW,gBAAgB,CAAC,UAAU,CAAC,EAAE,UAAU;;IAG3E;;;;;;;;OAQG;IACH,MAAM,CAAC,SAAS,+BAAwB;IAExC;;;;;OAKG;IACH,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,sBAAsB,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,GAAE,eAAoB,GAAG,WAAW;IAIjG;;OAEG;IACI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI;gBAInB,MAAM,EAAE,UAAU,EAAE,IAAI,GAAE,eAAoB;IAwM1D;;OAEG;IACI,IAAI,IAAI,cAAc,CAAC,UAAU,CAAC;IAgCzC;;OAEG;IACI,OAAO,IAAI,UAAU,EAAE;IAI9B;;OAEG;IACI,cAAc,CAAC,OAAO,6BAAoB,GAAG,MAAM,EAAE;IAIrD,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,gBAAgB,CAAC,UAAU,CAAC;CAGxD"}
|