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,118 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Sister Software
|
|
3
|
-
* @license MIT
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* A class to manage a buffer of bytes, growing and shrinking as needed.
|
|
8
|
-
*/
|
|
9
|
-
export class BufferController {
|
|
10
|
-
/**
|
|
11
|
-
* The initial size of the buffer.
|
|
12
|
-
*/
|
|
13
|
-
#initialBufferSize;
|
|
14
|
-
/**
|
|
15
|
-
* The underlying buffer containing the data.
|
|
16
|
-
*
|
|
17
|
-
* This property is mutable for performance reasons. Consumers should treat it as immutable.
|
|
18
|
-
*/
|
|
19
|
-
bytes;
|
|
20
|
-
/**
|
|
21
|
-
* The total number of bytes currently written to the buffer.
|
|
22
|
-
*
|
|
23
|
-
* This property is mutable for performance reasons. Consumers should treat it as immutable.
|
|
24
|
-
*/
|
|
25
|
-
bytesWritten;
|
|
26
|
-
/**
|
|
27
|
-
* The minimum byte length of the buffer.
|
|
28
|
-
*/
|
|
29
|
-
get byteLengthMinimum() {
|
|
30
|
-
return Math.max(this.bytesWritten, this.#initialBufferSize);
|
|
31
|
-
}
|
|
32
|
-
constructor(init) {
|
|
33
|
-
this.#initialBufferSize = init.initialBufferSize;
|
|
34
|
-
this.bytes = new Uint8Array(this.#initialBufferSize);
|
|
35
|
-
this.bytesWritten = 0;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Grow the buffer to the desired byte length, typically double the current byte length.
|
|
39
|
-
*/
|
|
40
|
-
grow(desiredByteLength) {
|
|
41
|
-
desiredByteLength ??= this.bytes.length * 2;
|
|
42
|
-
if (desiredByteLength <= this.bytes.length)
|
|
43
|
-
return;
|
|
44
|
-
// console.debug(`Growing buffer from ${this.bytes.length} to ${desiredByteLength} bytes.`)
|
|
45
|
-
const newBytes = new Uint8Array(desiredByteLength);
|
|
46
|
-
newBytes.set(this.bytes);
|
|
47
|
-
this.bytes = newBytes;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Modify the buffer in place, keeping only the bytes between the start and end indices.
|
|
51
|
-
*
|
|
52
|
-
* This is performed after we're confident that any data preceeding `start` or following `end` is no longer needed.
|
|
53
|
-
*
|
|
54
|
-
* `bytesWritten` is rebased onto the new window so it always reflects the count of valid bytes present after
|
|
55
|
-
* compression. Bytes outside the kept window are dropped from the count even if the underlying allocation is larger.
|
|
56
|
-
*
|
|
57
|
-
* @param start - The starting byte index of which bytes to keep.
|
|
58
|
-
* @param end - The ending byte index of which bytes to keep. Defaults to the current buffer length. Values past the
|
|
59
|
-
* buffer length are clamped.
|
|
60
|
-
*/
|
|
61
|
-
compress(start = 0, end = this.bytes.length) {
|
|
62
|
-
const clampedEnd = Math.min(end, this.bytes.length);
|
|
63
|
-
const validEnd = Math.min(this.bytesWritten, clampedEnd);
|
|
64
|
-
this.bytes = this.bytes.subarray(start, clampedEnd);
|
|
65
|
-
this.bytesWritten = Math.max(0, validEnd - start);
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Clear the buffer, zeroing out all bytes.
|
|
69
|
-
*
|
|
70
|
-
* @param begin The starting byte index from which to clear.
|
|
71
|
-
* @param end The ending byte index to clear.
|
|
72
|
-
*/
|
|
73
|
-
clear(begin = 0, end = this.bytesWritten) {
|
|
74
|
-
this.bytes.fill(0, begin, end);
|
|
75
|
-
this.bytesWritten = 0;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Gets a new Uint8Array view of the ArrayBuffer store for this array, referencing the elements at begin, inclusive,
|
|
79
|
-
* up to end, exclusive.
|
|
80
|
-
*
|
|
81
|
-
* @param begin — The index of the beginning of the array.
|
|
82
|
-
* @param end — The index of the end of the array
|
|
83
|
-
* @throws If the start index is greater than the end index.
|
|
84
|
-
* @throws If the end index is greater than the current byte length.
|
|
85
|
-
*/
|
|
86
|
-
subarray(begin = 0, end = this.bytesWritten) {
|
|
87
|
-
if (begin > end) {
|
|
88
|
-
throw new RangeError(`Start index ${begin} is greater than end index ${end}.`);
|
|
89
|
-
}
|
|
90
|
-
if (end > this.bytesWritten) {
|
|
91
|
-
throw new RangeError(`End index ${end} is greater than the current byte length ${this.bytesWritten}.`);
|
|
92
|
-
}
|
|
93
|
-
return this.bytes.subarray(begin, end);
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Sets a value or an array of values.
|
|
97
|
-
*
|
|
98
|
-
* Unlike the `TypedArray.set` method, this method will grow the buffer if the offset is greater than the current byte
|
|
99
|
-
* length.
|
|
100
|
-
*
|
|
101
|
-
* @param array — A typed or untyped array of values to set.
|
|
102
|
-
* @param offset — The index in the current array at which the values are to be written.
|
|
103
|
-
*
|
|
104
|
-
* @returns The number of bytes written.
|
|
105
|
-
*/
|
|
106
|
-
set(array, offset = 0) {
|
|
107
|
-
const nextLength = offset + array.length;
|
|
108
|
-
if (nextLength > this.bytes.length) {
|
|
109
|
-
this.grow(nextLength);
|
|
110
|
-
}
|
|
111
|
-
this.bytes.set(array, offset);
|
|
112
|
-
if (nextLength > this.bytesWritten) {
|
|
113
|
-
this.bytesWritten = nextLength;
|
|
114
|
-
}
|
|
115
|
-
return nextLength;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
//# sourceMappingURL=BufferController.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BufferController.js","sourceRoot":"","sources":["../../lib/BufferController.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,OAAO,gBAAgB;IAC5B;;OAEG;IACH,kBAAkB,CAAQ;IAE1B;;;;OAIG;IACH,KAAK,CAAY;IAEjB;;;;OAIG;IACH,YAAY,CAAQ;IAEpB;;OAEG;IACH,IAAW,iBAAiB;QAC3B,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAA;IAC5D,CAAC;IAED,YAAY,IAAmC;QAC9C,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,iBAAiB,CAAA;QAChD,IAAI,CAAC,KAAK,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,kBAAkB,CAAC,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G,GAAW,IAAI,CAAC,YAAY;QACzD,IAAI,KAAK,GAAG,GAAG,EAAE,CAAC;YACjB,MAAM,IAAI,UAAU,CAAC,eAAe,KAAK,8BAA8B,GAAG,GAAG,CAAC,CAAA;QAC/E,CAAC;QAED,IAAI,GAAG,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;YAC7B,MAAM,IAAI,UAAU,CAAC,aAAa,GAAG,4CAA4C,IAAI,CAAC,YAAY,GAAG,CAAC,CAAA;QACvG,CAAC;QAED,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;IACvC,CAAC;IAED;;;;;;;;;;OAUG;IACI,GAAG,CAAC,KAAwB,EAAE,MAAM,GAAG,CAAC;QAC9C,MAAM,UAAU,GAAG,MAAM,GAAG,KAAK,CAAC,MAAM,CAAA;QAExC,IAAI,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;YACpC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;QACtB,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;QAE7B,IAAI,UAAU,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;YACpC,IAAI,CAAC,YAAY,GAAG,UAAU,CAAA;QAC/B,CAAC;QAED,OAAO,UAAU,CAAA;IAClB,CAAC;CACD"}
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @copyright Sister Software
|
|
3
|
-
* @license MIT
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
*/
|
|
6
|
-
import { AsyncSequence } from "./AsyncSequence.js";
|
|
7
|
-
import { type CharacterSequenceInput } from "./CharacterSequence.js";
|
|
8
|
-
import { type RowEmitter, type RowOutputMode, type RowTransformer, type RowTransformerEntry, type RowTransformerRecord, type RowTuple } from "./row-emitters.js";
|
|
9
|
-
import type { AsyncChunkIterator, AsyncDataResource } from "./shared.js";
|
|
10
|
-
import { type AsyncSpliteratorInit, type SpliteratorInit } from "./Spliterator.js";
|
|
11
|
-
export type { RowTuple } from "./row-emitters.js";
|
|
12
|
-
/**
|
|
13
|
-
* An output mode for the CSV generator.
|
|
14
|
-
*/
|
|
15
|
-
export type CSVOutputMode = RowOutputMode;
|
|
16
|
-
export type CSVTransformer<T = unknown> = RowTransformer<string, T>;
|
|
17
|
-
export type CSVTransformerEntry<T = unknown> = RowTransformerEntry<string, T>;
|
|
18
|
-
export type CSVTransformerRecord = RowTransformerRecord<string>;
|
|
19
|
-
export type CSVEmitter<T = unknown> = RowEmitter<string, T>;
|
|
20
|
-
export type CSVSpliteratorEmittedRecord<V = string | number | undefined> = Record<string, V>;
|
|
21
|
-
export declare const CSVSpliteratorEmitters: Record<CSVOutputMode, CSVEmitter | null>;
|
|
22
|
-
export interface CSVSpliteratorInit extends SpliteratorInit {
|
|
23
|
-
/**
|
|
24
|
-
* The mode determines the shape of the data emitted by the generator.
|
|
25
|
-
*
|
|
26
|
-
* - `object` will emit each row as an object with the header names as keys.
|
|
27
|
-
* - `array` will emit each row as an array.
|
|
28
|
-
* - `entries` will emit each row as an array of key-value pairs.
|
|
29
|
-
*
|
|
30
|
-
* Note that {@linkcode CSVSpliteratorInit.header} defaults to `true` in every mode — the first row is consumed as the
|
|
31
|
-
* header even in `array` mode. Pass `header: false` for headerless data.
|
|
32
|
-
*
|
|
33
|
-
* When {@linkcode SpliteratorInit.enableQuoteHandling} is set, quoting is handled end-to-end: rows do not split on
|
|
34
|
-
* delimiters inside quotes (embedded newlines stay in their row), columns do not split on quoted column delimiters,
|
|
35
|
-
* wrapping quotes are stripped, and doubled quotes (`""`) unescape to `"`.
|
|
36
|
-
*
|
|
37
|
-
* {@linkcode SpliteratorInit.crlf} defaults to `true` here (unlike everywhere else): RFC 4180 mandates CRLF row
|
|
38
|
-
* terminators, so a correct CSV parser must accept them without leaking `\r` into the last column.
|
|
39
|
-
*/
|
|
40
|
-
mode?: CSVOutputMode;
|
|
41
|
-
/**
|
|
42
|
-
* The delimiter to use for columns in a row.
|
|
43
|
-
*
|
|
44
|
-
* @default Delimiter.Comma
|
|
45
|
-
*/
|
|
46
|
-
columnDelimiter?: CharacterSequenceInput;
|
|
47
|
-
/**
|
|
48
|
-
* Whether to normalize the keys of the header row into `snake_case`, and to disambiguate duplicates by suffixing
|
|
49
|
-
* `_2`, `_3`, … — making them usable as object keys.
|
|
50
|
-
*
|
|
51
|
-
* **A header that is already ALL CAPS is left alone**, on the reasoning that its casing is deliberate. So an
|
|
52
|
-
* OpenAddresses header (`LON,LAT,NUMBER,STREET`) normalizes to `LON`/`NUMBER`, NOT `lon`/`number`, and a row is read
|
|
53
|
-
* as `row.STREET`. Lower-case your own keys if you want case-folding — this option does not provide it.
|
|
54
|
-
*
|
|
55
|
-
* @default `mode !== "array"` — object and entries rows need keyable names; array rows have no keys to normalize.
|
|
56
|
-
*/
|
|
57
|
-
normalizeKeys?: boolean;
|
|
58
|
-
/**
|
|
59
|
-
* Whether to treat the first row as a header.
|
|
60
|
-
*
|
|
61
|
-
* @default true
|
|
62
|
-
*/
|
|
63
|
-
header?: boolean;
|
|
64
|
-
transformers?: Iterable<CSVTransformerEntry> | CSVTransformerRecord;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* A static class spliterator for comma-separated values.
|
|
68
|
-
*
|
|
69
|
-
* **Performance:** the SIMD delimiter scan wins when scanning dominates — many rows, a few columns pulled out cheaply,
|
|
70
|
-
* streaming to bound memory. When per-row work is heavy (a full `JSON.parse`, expensive transforms) it can dominate the
|
|
71
|
-
* scan and erase the advantage; benchmark against a mature native parser before swapping an existing loop for speed.
|
|
72
|
-
* See {@link JSONSpliterator} for the measured case where per-row `JSON.parse` makes the streamed path a net loss.
|
|
73
|
-
*
|
|
74
|
-
* @see {@linkcode CSVSpliterator.from} for synchronous usage.
|
|
75
|
-
* @see {@linkcode CSVSpliterator.fromAsync} for asynchronous usage.
|
|
76
|
-
*/
|
|
77
|
-
export declare abstract class CSVSpliterator {
|
|
78
|
-
/**
|
|
79
|
-
* The column delimiter used by the spliterator.
|
|
80
|
-
*
|
|
81
|
-
* @default Delimiters.Comma
|
|
82
|
-
*/
|
|
83
|
-
static ColumnDelimiter: number;
|
|
84
|
-
constructor();
|
|
85
|
-
static from<T extends CSVSpliteratorEmittedRecord = CSVSpliteratorEmittedRecord>(source: CharacterSequenceInput, options?: CSVSpliteratorInit & {
|
|
86
|
-
mode: "object";
|
|
87
|
-
}): Generator<T>;
|
|
88
|
-
/**
|
|
89
|
-
* @yields Each row as a 3-tuple [key, value, idx].
|
|
90
|
-
*/
|
|
91
|
-
static from<T extends RowTuple[] = RowTuple[]>(source: CharacterSequenceInput, options?: CSVSpliteratorInit & {
|
|
92
|
-
mode: "entries";
|
|
93
|
-
}): Generator<T>;
|
|
94
|
-
/**
|
|
95
|
-
* Given a byte array or string, yield each row as an array of columns.
|
|
96
|
-
*
|
|
97
|
-
* @yields Each row as an array of columns.
|
|
98
|
-
*/
|
|
99
|
-
static from<T extends string[] = string[]>(source: CharacterSequenceInput, options?: CSVSpliteratorInit & {
|
|
100
|
-
mode?: "array";
|
|
101
|
-
}): Generator<T>;
|
|
102
|
-
/**
|
|
103
|
-
* @yields Each row as an object with the header names as keys.
|
|
104
|
-
*/
|
|
105
|
-
static fromAsync<T extends CSVSpliteratorEmittedRecord = CSVSpliteratorEmittedRecord>(source: AsyncDataResource | AsyncChunkIterator, options?: CSVSpliteratorInit & AsyncSpliteratorInit & {
|
|
106
|
-
mode: "object";
|
|
107
|
-
}): AsyncSequence<T>;
|
|
108
|
-
/**
|
|
109
|
-
* @yields Each row as a 3-tuple [key, value, idx].
|
|
110
|
-
*/
|
|
111
|
-
static fromAsync<T extends RowTuple[] = RowTuple[]>(source: AsyncDataResource | AsyncChunkIterator, options?: CSVSpliteratorInit & AsyncSpliteratorInit & {
|
|
112
|
-
mode: "entries";
|
|
113
|
-
}): AsyncSequence<T>;
|
|
114
|
-
/**
|
|
115
|
-
* @yields Each row as an array of columns.
|
|
116
|
-
*/
|
|
117
|
-
static fromAsync<T extends string[] = string[]>(source: AsyncDataResource | AsyncChunkIterator, options?: CSVSpliteratorInit & AsyncSpliteratorInit & {
|
|
118
|
-
mode?: "array";
|
|
119
|
-
}): AsyncSequence<T>;
|
|
120
|
-
/**
|
|
121
|
-
* Given an asychronous data source, splits the data by rows(usually by newline) and then by columns (usually by
|
|
122
|
-
* comma).
|
|
123
|
-
*
|
|
124
|
-
* @param source The data source to split.
|
|
125
|
-
* @param init Options for the spliterator.
|
|
126
|
-
*
|
|
127
|
-
* @yields Each row, shaped according to the `mode` option.
|
|
128
|
-
*/
|
|
129
|
-
static fromAsync(source: AsyncDataResource | AsyncChunkIterator, init?: CSVSpliteratorInit & AsyncSpliteratorInit): AsyncSequence<unknown>;
|
|
130
|
-
}
|
|
131
|
-
//# sourceMappingURL=CSVSpliterator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CSVSpliterator.d.ts","sourceRoot":"","sources":["../../lib/CSVSpliterator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD,OAAO,EAAqB,KAAK,sBAAsB,EAAc,MAAM,wBAAwB,CAAA;AACnG,OAAO,EAGN,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,QAAQ,EACb,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AACxE,OAAO,EAAE,KAAK,oBAAoB,EAAe,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAE/F,YAAY,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAEjD;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,aAAa,CA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;;;;;;;OAQG;IACH,MAAM,CAAC,SAAS,CACf,MAAM,EAAE,iBAAiB,GAAG,kBAAkB,EAC9C,IAAI,CAAC,EAAE,kBAAkB,GAAG,oBAAoB,GAC9C,aAAa,CAAC,OAAO,CAAC,CAAA;CA8EzB"}
|
|
@@ -1,172 +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 { normalizeColumnNames } from "./casing.js";
|
|
9
|
-
import { CharacterSequence, Delimiters } from "./CharacterSequence.js";
|
|
10
|
-
import { bindTransformers, createRowEmitters, } from "./row-emitters.js";
|
|
11
|
-
import { Spliterator } from "./Spliterator.js";
|
|
12
|
-
const doubleQuoteSequence = new CharacterSequence('"');
|
|
13
|
-
/**
|
|
14
|
-
* Decode a single column, stripping wrapping quotes and unescaping doubled quotes (`""` → `"`) when quote handling is
|
|
15
|
-
* on. The unescape allocates only when the field was actually quoted.
|
|
16
|
-
*/
|
|
17
|
-
function decodeColumn(bytes, decoder, enableQuoteHandling) {
|
|
18
|
-
const value = decoder.decode(bytes);
|
|
19
|
-
if (enableQuoteHandling && value.length >= 2 && value.startsWith('"') && value.endsWith('"')) {
|
|
20
|
-
return value.slice(1, -1).replaceAll('""', '"');
|
|
21
|
-
}
|
|
22
|
-
return value;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Split one row's bytes into decoded column strings.
|
|
26
|
-
*
|
|
27
|
-
* Without quote handling this is a plain delimiter scan. With it, a column delimiter inside a double-quoted region does
|
|
28
|
-
* not split, and each field is unquoted/unescaped via {@linkcode decodeColumn}. Empty columns are always preserved — a
|
|
29
|
-
* 30-column row must stay 30 columns regardless of the caller's row-level `skipEmpty`.
|
|
30
|
-
*/
|
|
31
|
-
function splitRowColumns(row, columnDelimiter, decoder, enableQuoteHandling) {
|
|
32
|
-
if (!enableQuoteHandling) {
|
|
33
|
-
return columnDelimiter.searchAll(row).map(([start, end]) => decoder.decode(row.subarray(start, end)));
|
|
34
|
-
}
|
|
35
|
-
const columns = [];
|
|
36
|
-
let sliceStart = 0;
|
|
37
|
-
let insideQuotes = false;
|
|
38
|
-
for (const match of columnDelimiter.searchMatches(row, doubleQuoteSequence)) {
|
|
39
|
-
if (match.patternId === 1) {
|
|
40
|
-
insideQuotes = !insideQuotes;
|
|
41
|
-
continue;
|
|
42
|
-
}
|
|
43
|
-
if (insideQuotes)
|
|
44
|
-
continue;
|
|
45
|
-
columns.push(decodeColumn(row.subarray(sliceStart, match.offset), decoder, enableQuoteHandling));
|
|
46
|
-
sliceStart = match.offset + columnDelimiter.length;
|
|
47
|
-
}
|
|
48
|
-
columns.push(decodeColumn(row.subarray(sliceStart), decoder, enableQuoteHandling));
|
|
49
|
-
return columns;
|
|
50
|
-
}
|
|
51
|
-
export const CSVSpliteratorEmitters = createRowEmitters("");
|
|
52
|
-
/**
|
|
53
|
-
* A static class spliterator for comma-separated values.
|
|
54
|
-
*
|
|
55
|
-
* **Performance:** the SIMD delimiter scan wins when scanning dominates — many rows, a few columns pulled out cheaply,
|
|
56
|
-
* streaming to bound memory. When per-row work is heavy (a full `JSON.parse`, expensive transforms) it can dominate the
|
|
57
|
-
* scan and erase the advantage; benchmark against a mature native parser before swapping an existing loop for speed.
|
|
58
|
-
* See {@link JSONSpliterator} for the measured case where per-row `JSON.parse` makes the streamed path a net loss.
|
|
59
|
-
*
|
|
60
|
-
* @see {@linkcode CSVSpliterator.from} for synchronous usage.
|
|
61
|
-
* @see {@linkcode CSVSpliterator.fromAsync} for asynchronous usage.
|
|
62
|
-
*/
|
|
63
|
-
export class CSVSpliterator {
|
|
64
|
-
/**
|
|
65
|
-
* The column delimiter used by the spliterator.
|
|
66
|
-
*
|
|
67
|
-
* @default Delimiters.Comma
|
|
68
|
-
*/
|
|
69
|
-
static ColumnDelimiter = Delimiters.Comma;
|
|
70
|
-
constructor() {
|
|
71
|
-
throw new TypeError("Static class cannot be instantiated. Did you mean `CSVSpliterator.from`?");
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Given a byte array or string, yield each row as an array of columns.
|
|
75
|
-
*
|
|
76
|
-
* @yields Each row as an array of columns.
|
|
77
|
-
*/
|
|
78
|
-
static *from(source, init = {}) {
|
|
79
|
-
const {
|
|
80
|
-
// ---
|
|
81
|
-
header = true,
|
|
82
|
-
// `mode` is destructured before `normalizeKeys` because the latter's default reads it.
|
|
83
|
-
mode = "array", transformers: transformersInput = [],
|
|
84
|
-
// Matches `fromAsync`. These two defaulted differently until 4.0.1, so the same options
|
|
85
|
-
// object produced `row.some_name` from one entry point and `row["Some Name"]` from the other.
|
|
86
|
-
normalizeKeys = mode !== "array", columnDelimiter: columnDelimiterInput = this.ColumnDelimiter, enableQuoteHandling = false,
|
|
87
|
-
// RFC 4180 mandates CRLF row terminators — accept them by default so the last column
|
|
88
|
-
// never carries a stray `\r` on Windows-lineage sources.
|
|
89
|
-
crlf = true, take = Infinity, drop = 0, ...rowInit } = init;
|
|
90
|
-
const emitter = CSVSpliteratorEmitters[mode];
|
|
91
|
-
let transformers = [];
|
|
92
|
-
let yieldCount = 0;
|
|
93
|
-
const yieldLimit = take + drop;
|
|
94
|
-
const decoder = new TextDecoder();
|
|
95
|
-
const columnDelimiter = new CharacterSequence(columnDelimiterInput ?? this.ColumnDelimiter);
|
|
96
|
-
// Quote handling applies at both levels: rows must not split on newlines inside quotes,
|
|
97
|
-
// columns must not split on quoted column delimiters.
|
|
98
|
-
const rows = Spliterator.fromSync(source, { ...rowInit, crlf, enableQuoteHandling });
|
|
99
|
-
if (header) {
|
|
100
|
-
const result = rows.next();
|
|
101
|
-
if (result.done)
|
|
102
|
-
return;
|
|
103
|
-
const columns = splitRowColumns(result.value, columnDelimiter, decoder, enableQuoteHandling);
|
|
104
|
-
const headers = normalizeKeys ? normalizeColumnNames(columns) : columns;
|
|
105
|
-
transformers = bindTransformers(headers, transformersInput);
|
|
106
|
-
}
|
|
107
|
-
for (const row of rows) {
|
|
108
|
-
if (yieldCount < drop) {
|
|
109
|
-
yieldCount++;
|
|
110
|
-
continue;
|
|
111
|
-
}
|
|
112
|
-
if (yieldCount >= yieldLimit)
|
|
113
|
-
break;
|
|
114
|
-
const columns = splitRowColumns(row, columnDelimiter, decoder, enableQuoteHandling);
|
|
115
|
-
yield emitter ? emitter(columns, transformers) : columns;
|
|
116
|
-
yieldCount++;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Given an asychronous data source, splits the data by rows (usually by newline) and then by columns (usually by
|
|
121
|
-
* comma).
|
|
122
|
-
*
|
|
123
|
-
* @param source The data source to split.
|
|
124
|
-
* @param init Options for the spliterator.
|
|
125
|
-
*
|
|
126
|
-
* @yields Each row, shaped according to the `mode` option.
|
|
127
|
-
*/
|
|
128
|
-
static fromAsync(source, init = {}) {
|
|
129
|
-
const defaultColumnDelimiter = this.ColumnDelimiter;
|
|
130
|
-
const {
|
|
131
|
-
// ---
|
|
132
|
-
header = true, mode = "array", transformers: transformersInput = [], normalizeKeys = mode !== "array", columnDelimiter: columnDelimiterInput, enableQuoteHandling = false,
|
|
133
|
-
// RFC 4180 mandates CRLF row terminators — accept them by default so the last column
|
|
134
|
-
// never carries a stray `\r` on Windows-lineage sources.
|
|
135
|
-
crlf = true, take = Infinity, drop = 0, ...rowInit } = init;
|
|
136
|
-
const emitter = CSVSpliteratorEmitters[mode];
|
|
137
|
-
const columnDelimiter = new CharacterSequence(columnDelimiterInput ?? defaultColumnDelimiter);
|
|
138
|
-
const decoder = new TextDecoder();
|
|
139
|
-
// Populated by the header pass below before the first row op runs, since the source thunk resolves on the first
|
|
140
|
-
// pull and the ops only run against what it returns.
|
|
141
|
-
let transformers = [];
|
|
142
|
-
const openRows = async () => {
|
|
143
|
-
// Quote handling applies at both levels: rows must not split on newlines inside quotes,
|
|
144
|
-
// columns must not split on quoted column delimiters.
|
|
145
|
-
const rows = await openDelimitedRows(source, { ...rowInit, crlf, enableQuoteHandling });
|
|
146
|
-
if (header) {
|
|
147
|
-
// Both engines return `this` from their iterator method, so consuming the header row here advances the very
|
|
148
|
-
// cursor the row ops will go on to read — returning `rows` afterwards resumes at row two, not row one.
|
|
149
|
-
const iterator = Symbol.asyncIterator in rows ? rows[Symbol.asyncIterator]() : rows[Symbol.iterator]();
|
|
150
|
-
const result = await iterator.next();
|
|
151
|
-
if (result.done)
|
|
152
|
-
return rows;
|
|
153
|
-
const columns = splitRowColumns(result.value, columnDelimiter, decoder, enableQuoteHandling);
|
|
154
|
-
const headers = normalizeKeys ? normalizeColumnNames(columns) : columns;
|
|
155
|
-
transformers = bindTransformers(headers, transformersInput);
|
|
156
|
-
}
|
|
157
|
-
return rows;
|
|
158
|
-
};
|
|
159
|
-
let sequence = AsyncSequence.from(openRows).map((row) => {
|
|
160
|
-
const columns = splitRowColumns(row, columnDelimiter, decoder, enableQuoteHandling);
|
|
161
|
-
return emitter ? emitter(columns, transformers) : columns;
|
|
162
|
-
});
|
|
163
|
-
if (drop > 0) {
|
|
164
|
-
sequence = sequence.drop(drop);
|
|
165
|
-
}
|
|
166
|
-
if (Number.isFinite(take)) {
|
|
167
|
-
sequence = sequence.take(take);
|
|
168
|
-
}
|
|
169
|
-
return sequence;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
//# sourceMappingURL=CSVSpliterator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CSVSpliterator.js","sourceRoot":"","sources":["../../lib/CSVSpliterator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAA2B,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AACjF,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;A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@copyright Sister Software
|
|
3
|
-
* @license MIT
|
|
4
|
-
* @author Teffen Ellis, et al.
|
|
5
|
-
*/
|
|
6
|
-
import type { PathBuilderLike } from "path-ts";
|
|
7
|
-
import type { ByteRange } from "./shared.js";
|
|
8
|
-
import { type MatchResult, type WasmRangeScanResult } from "./wasm_module.js";
|
|
9
|
-
export declare function isArrayLike<T>(input: unknown): input is ArrayLike<T>;
|
|
10
|
-
export type CharacterSequenceInput = number | string | DataView | ArrayBuffer | Buffer | Iterable<number> | PathBuilderLike;
|
|
11
|
-
export declare const Delimiters: {
|
|
12
|
-
readonly Null: 0;
|
|
13
|
-
readonly LineFeed: 10;
|
|
14
|
-
readonly CarriageReturn: 13;
|
|
15
|
-
readonly Comma: 44;
|
|
16
|
-
readonly Tab: 9;
|
|
17
|
-
readonly Space: 32;
|
|
18
|
-
readonly One: 49;
|
|
19
|
-
readonly Zero: 48;
|
|
20
|
-
readonly DoubleQuote: 34;
|
|
21
|
-
readonly RecordSeparator: 30;
|
|
22
|
-
readonly Pipe: 124;
|
|
23
|
-
};
|
|
24
|
-
export declare const VisibleDelimiterMap: Map<number, string>;
|
|
25
|
-
export declare function debugAsVisibleCharacters(delimiter: Uint8Array): string;
|
|
26
|
-
export declare function normalizeCharacterInput(input: CharacterSequenceInput): Uint8Array;
|
|
27
|
-
export declare class CharacterSequence extends Uint8Array {
|
|
28
|
-
#private;
|
|
29
|
-
/**
|
|
30
|
-
* Resolve once the WASM SIMD scanner has finished loading, yielding whether it is active.
|
|
31
|
-
*
|
|
32
|
-
* The module loads asynchronously, so synchronous callers (`Spliterator.fromSync`, `CSVSpliterator.from`) that run to
|
|
33
|
-
* completion in a single tick would otherwise always fall back to the JS scanner. Await this first to opt into SIMD
|
|
34
|
-
* acceleration.
|
|
35
|
-
*/
|
|
36
|
-
static whenReady(): Promise<boolean>;
|
|
37
|
-
search(haystack: Uint8Array, start?: number, end?: number): number;
|
|
38
|
-
searchAll(haystack: Uint8Array, start?: number, end?: number): ByteRange[];
|
|
39
|
-
/**
|
|
40
|
-
* Scan completed ranges in one bounded, resumable WASM call.
|
|
41
|
-
*
|
|
42
|
-
* This is the low-allocation streaming primitive: unlike {@link searchMatches}, it carries quote state and range
|
|
43
|
-
* boundaries through the native scan and exposes the packed result view directly. The returned view aliases shared
|
|
44
|
-
* WASM memory and must be consumed before another scanner call.
|
|
45
|
-
*
|
|
46
|
-
* Returns `null` when the SIMD module is unavailable, the delimiter/quote is not one byte, or the buffer is below the
|
|
47
|
-
* WASM threshold. Callers must retain their existing JavaScript path as the fallback.
|
|
48
|
-
*/
|
|
49
|
-
scanRanges(haystack: Uint8Array, state: {
|
|
50
|
-
scanCursor: number;
|
|
51
|
-
pendingSliceStart: number;
|
|
52
|
-
insideQuotes: boolean;
|
|
53
|
-
}, end?: number, quotePattern?: Uint8Array, maxRanges?: number): WasmRangeScanResult | null;
|
|
54
|
-
/**
|
|
55
|
-
* Scan for two patterns simultaneously (delimiter + quote) for CSV parsing.
|
|
56
|
-
*
|
|
57
|
-
* Returns sorted MatchResult[] with patternId 0=delimiter, 1=quote. Uses WASM SIMD double-scan when available; JS
|
|
58
|
-
* fallback otherwise.
|
|
59
|
-
*/
|
|
60
|
-
searchMatches(haystack: Uint8Array, quotePattern: Uint8Array, start?: number, end?: number): MatchResult[];
|
|
61
|
-
/**
|
|
62
|
-
* Adopt a pattern as a sequence, reusing it when it already is one.
|
|
63
|
-
*
|
|
64
|
-
* Constructing a sequence builds a 256-entry skip table, so wrapping unconditionally puts that allocation on every
|
|
65
|
-
* call of a per-row scan. Every in-tree caller of {@linkcode searchMatches} already holds a long-lived sequence for
|
|
66
|
-
* its quote pattern.
|
|
67
|
-
*/
|
|
68
|
-
static asSequence(pattern: Uint8Array): CharacterSequence;
|
|
69
|
-
decode(encoding?: string): string;
|
|
70
|
-
constructor(input?: CharacterSequenceInput);
|
|
71
|
-
}
|
|
72
|
-
//# sourceMappingURL=CharacterSequence.d.ts.map
|
|
@@ -1 +0,0 @@
|
|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