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.
Files changed (75) hide show
  1. package/LICENSE.md +650 -0
  2. package/README.md +119 -0
  3. package/out/index.d.ts +21 -0
  4. package/out/index.d.ts.map +1 -0
  5. package/out/index.js +21 -0
  6. package/out/index.js.map +1 -0
  7. package/out/lib/AsyncSpliterator.d.ts +127 -0
  8. package/out/lib/AsyncSpliterator.d.ts.map +1 -0
  9. package/out/lib/AsyncSpliterator.js +332 -0
  10. package/out/lib/AsyncSpliterator.js.map +1 -0
  11. package/out/lib/BufferController.d.ts +62 -0
  12. package/out/lib/BufferController.d.ts.map +1 -0
  13. package/out/lib/BufferController.js +93 -0
  14. package/out/lib/BufferController.js.map +1 -0
  15. package/out/lib/CSVSpliterator.d.ts +104 -0
  16. package/out/lib/CSVSpliterator.d.ts.map +1 -0
  17. package/out/lib/CSVSpliterator.js +83 -0
  18. package/out/lib/CSVSpliterator.js.map +1 -0
  19. package/out/lib/CharacterSequence.d.ts +103 -0
  20. package/out/lib/CharacterSequence.d.ts.map +1 -0
  21. package/out/lib/CharacterSequence.js +184 -0
  22. package/out/lib/CharacterSequence.js.map +1 -0
  23. package/out/lib/CompositeDataView.d.ts +104 -0
  24. package/out/lib/CompositeDataView.d.ts.map +1 -0
  25. package/out/lib/CompositeDataView.js +242 -0
  26. package/out/lib/CompositeDataView.js.map +1 -0
  27. package/out/lib/DelimitedChunkReader.d.ts +67 -0
  28. package/out/lib/DelimitedChunkReader.d.ts.map +1 -0
  29. package/out/lib/DelimitedChunkReader.js +113 -0
  30. package/out/lib/DelimitedChunkReader.js.map +1 -0
  31. package/out/lib/DelimiterTransformer.d.ts +27 -0
  32. package/out/lib/DelimiterTransformer.d.ts.map +1 -0
  33. package/out/lib/DelimiterTransformer.js +26 -0
  34. package/out/lib/DelimiterTransformer.js.map +1 -0
  35. package/out/lib/IndexQueue.d.ts +48 -0
  36. package/out/lib/IndexQueue.d.ts.map +1 -0
  37. package/out/lib/IndexQueue.js +80 -0
  38. package/out/lib/IndexQueue.js.map +1 -0
  39. package/out/lib/JSONSpliterator.d.ts +19 -0
  40. package/out/lib/JSONSpliterator.d.ts.map +1 -0
  41. package/out/lib/JSONSpliterator.js +55 -0
  42. package/out/lib/JSONSpliterator.js.map +1 -0
  43. package/out/lib/SlidingWindow.d.ts +93 -0
  44. package/out/lib/SlidingWindow.d.ts.map +1 -0
  45. package/out/lib/SlidingWindow.js +176 -0
  46. package/out/lib/SlidingWindow.js.map +1 -0
  47. package/out/lib/Spliterator.d.ts +51 -0
  48. package/out/lib/Spliterator.d.ts.map +1 -0
  49. package/out/lib/Spliterator.js +238 -0
  50. package/out/lib/Spliterator.js.map +1 -0
  51. package/out/lib/TextSpliterator.d.ts +40 -0
  52. package/out/lib/TextSpliterator.d.ts.map +1 -0
  53. package/out/lib/TextSpliterator.js +56 -0
  54. package/out/lib/TextSpliterator.js.map +1 -0
  55. package/out/lib/casing.d.ts +28 -0
  56. package/out/lib/casing.d.ts.map +1 -0
  57. package/out/lib/casing.js +69 -0
  58. package/out/lib/casing.js.map +1 -0
  59. package/out/lib/node/fs.d.ts +98 -0
  60. package/out/lib/node/fs.d.ts.map +1 -0
  61. package/out/lib/node/fs.js +162 -0
  62. package/out/lib/node/fs.js.map +1 -0
  63. package/out/lib/shared.d.ts +167 -0
  64. package/out/lib/shared.d.ts.map +1 -0
  65. package/out/lib/shared.js +92 -0
  66. package/out/lib/shared.js.map +1 -0
  67. package/out/lib/take.d.ts +26 -0
  68. package/out/lib/take.d.ts.map +1 -0
  69. package/out/lib/take.js +71 -0
  70. package/out/lib/take.js.map +1 -0
  71. package/out/lib/writer.d.ts +34 -0
  72. package/out/lib/writer.d.ts.map +1 -0
  73. package/out/lib/writer.js +41 -0
  74. package/out/lib/writer.js.map +1 -0
  75. package/package.json +100 -0
@@ -0,0 +1,238 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ */
6
+ import { AsyncSpliterator } from "./AsyncSpliterator.js";
7
+ import { CharacterSequence, normalizeCharacterInput } from "./CharacterSequence.js";
8
+ import { IndexQueue } from "./IndexQueue.js";
9
+ export { AsyncSpliterator };
10
+ /**
11
+ * A byte stream delimiting iterator.
12
+ */
13
+ export class Spliterator {
14
+ //#region Lifecycle
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 = 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(source, init = {}) {
32
+ return new Spliterator(normalizeCharacterInput(source), init);
33
+ }
34
+ /**
35
+ * Dispose of the spliterator, closing the file handle if necessary.
36
+ */
37
+ [Symbol.dispose]() {
38
+ this.#indices.clear();
39
+ }
40
+ constructor(source, init = {}) {
41
+ this.#source = source;
42
+ this.#needle = new CharacterSequence(init.delimiter);
43
+ this.#readPosition = init.position ?? 0;
44
+ this.#highWaterMark = Math.max(this.#needle.length * 4, 4096);
45
+ this.#yieldDropCount = Math.max(0, init.drop ?? 0);
46
+ this.#yieldStopCount = Math.max(init.take ?? Infinity, 0) + this.#yieldDropCount;
47
+ this.#yieldByteEstimate = this.#source.byteLength - this.#readPosition;
48
+ this.#skipEmpty = init.skipEmpty ?? true;
49
+ this.#debug = init.debug ?? false;
50
+ this.#log = this.#debug ? console.debug.bind(console) : () => void 0;
51
+ }
52
+ //#endregion
53
+ //#region Private Properties
54
+ /**
55
+ * The byte source to read from.
56
+ */
57
+ #source;
58
+ /**
59
+ * A queue of index tuples marking the start and end of delimiter positions.
60
+ *
61
+ * Note that indices are relative to the buffer, not the file.
62
+ *
63
+ * This means that the start index is always 0, and the end index is the byte length of the
64
+ * buffer.
65
+ */
66
+ #indices = new IndexQueue();
67
+ /**
68
+ * The byte sequence to search for, i.e. an encoded delimiter.
69
+ */
70
+ #needle;
71
+ /**
72
+ * How many yields to skip.
73
+ */
74
+ #yieldDropCount;
75
+ /**
76
+ * How many yields to allow before stopping.
77
+ */
78
+ #yieldStopCount;
79
+ /**
80
+ * The total number of bytes we expect to yield.
81
+ *
82
+ * We use this to ensure that we don't miss any data as we read through the buffer.
83
+ */
84
+ #yieldByteEstimate;
85
+ /**
86
+ * Whether to skip empty yields.
87
+ */
88
+ #skipEmpty;
89
+ /**
90
+ * The high water mark for the buffer.
91
+ *
92
+ * This defines the total size of indices to keep in memory.
93
+ */
94
+ #highWaterMark;
95
+ /**
96
+ * The total number of bytes we've yielded.
97
+ */
98
+ #yieldedByteLength = 0;
99
+ /**
100
+ * The total number of yields.
101
+ */
102
+ #yieldCount = 0;
103
+ /**
104
+ * The current byte index to perform read operations from.
105
+ */
106
+ #readPosition;
107
+ /**
108
+ * The last byte range seen while draining the buffer.
109
+ */
110
+ #lastByteRangeSeen;
111
+ /**
112
+ * Whether to output debug information.
113
+ */
114
+ #debug;
115
+ /**
116
+ * Whether the iterator is done.
117
+ */
118
+ #done = false;
119
+ //#endregion
120
+ //#region Private Methods
121
+ #log;
122
+ #finalize() {
123
+ if (this.#debug) {
124
+ /**
125
+ * The total number of bytes we expect to be omitted from the buffer. This is derived from the
126
+ * number of of yields and the length of the delimiter.
127
+ */
128
+ const expectedYieldedDelimitedBytes = (this.#yieldCount - 1) * this.#needle.length;
129
+ const omittedBytes = this.#yieldByteEstimate - (this.#yieldedByteLength + expectedYieldedDelimitedBytes);
130
+ this.#log({
131
+ totalByteSize: this.#source.byteLength,
132
+ readPosition: this.#readPosition,
133
+ yieldByteEstimate: this.#yieldByteEstimate,
134
+ yieldedByteLength: this.#yieldedByteLength,
135
+ yieldCount: this.#yieldCount,
136
+ expectedYieldedDelimitedBytes,
137
+ omittedBytes,
138
+ });
139
+ }
140
+ return {
141
+ done: true,
142
+ value: undefined,
143
+ };
144
+ }
145
+ /**
146
+ * Fill the buffer with data and search for delimiters.
147
+ */
148
+ #fill() {
149
+ const sourceByteLength = this.#source.byteLength;
150
+ if (this.#readPosition === sourceByteLength) {
151
+ this.#log("Reached end of file. Preparing to finalize.");
152
+ // There's a few special cases we could get this far and not have drained the buffer.
153
+ const lastByteRange = this.#lastByteRangeSeen;
154
+ if (lastByteRange) {
155
+ const lastByteIndex = lastByteRange[1];
156
+ // There's a special case where the last delimiter is at the end of the *file*.
157
+ if (lastByteIndex < sourceByteLength) {
158
+ // We need to determine if we're at the end of the *file* and there's no delimiter.
159
+ const possibleDelimiterIndex = this.#needle.search(this.#source, sourceByteLength - this.#needle.length);
160
+ if (possibleDelimiterIndex !== -1) {
161
+ this.#log("Inserted byte range at the last delimiter", [possibleDelimiterIndex, sourceByteLength]);
162
+ // We found a delimiter at the end of the file, so we enqueue the byte range.
163
+ this.#indices.enqueue([possibleDelimiterIndex + this.#needle.length, sourceByteLength]);
164
+ }
165
+ else {
166
+ this.#log("Inserted byte range at the last byte", [lastByteIndex, sourceByteLength]);
167
+ // The file didn't end with a delimiter, so we just enqueue the last byte range.
168
+ this.#indices.enqueue([lastByteIndex + this.#needle.length, sourceByteLength]);
169
+ }
170
+ }
171
+ else {
172
+ this.#log(`Weird situation. We're at the end of the file, but the last byte range ${lastByteIndex} is greater than the buffer length ${sourceByteLength}.`);
173
+ }
174
+ }
175
+ else if (this.#yieldCount === 0) {
176
+ // We didn't find any delimiters in the file, so we just enqueue the whole buffer.
177
+ this.#indices.enqueue([0, sourceByteLength]);
178
+ }
179
+ this.#done = true;
180
+ return;
181
+ }
182
+ while (this.#readPosition < sourceByteLength && this.#indices.byteLength < this.#highWaterMark) {
183
+ // Unlike the async version, we can keep reading until our indices match the high water mark.
184
+ const delimiterIndex = this.#needle.search(this.#source, this.#readPosition);
185
+ if (delimiterIndex === -1) {
186
+ this.#log(`No viable byte range found in buffer. Breaking.`);
187
+ break;
188
+ }
189
+ this.#log("Found byte range", [this.#readPosition, delimiterIndex]);
190
+ this.#indices.enqueue([this.#readPosition, delimiterIndex]);
191
+ this.#readPosition = delimiterIndex + this.#needle.length;
192
+ }
193
+ }
194
+ //#endregion
195
+ //#region Iterator Methods
196
+ /**
197
+ * Read the next byte range from the source.
198
+ */
199
+ next() {
200
+ if (this.#done || this.#yieldCount >= this.#yieldStopCount)
201
+ return this.#finalize();
202
+ if (this.#indices.size === 0) {
203
+ this.#fill();
204
+ }
205
+ const currentByteRange = this.#indices.dequeue();
206
+ this.#lastByteRangeSeen = currentByteRange;
207
+ const [start, end] = currentByteRange;
208
+ const slice = this.#source.subarray(start, end);
209
+ if (slice.length === 0 && this.#skipEmpty) {
210
+ return this.next();
211
+ }
212
+ this.#yieldCount++;
213
+ if (this.#yieldCount <= this.#yieldDropCount) {
214
+ return this.next();
215
+ }
216
+ this.#yieldedByteLength += end - start;
217
+ return {
218
+ value: slice,
219
+ done: false,
220
+ };
221
+ }
222
+ /**
223
+ * Collect all the byte ranges from the file.
224
+ */
225
+ toArray() {
226
+ return Array.from(this);
227
+ }
228
+ /**
229
+ * Collect all the byte ranges from the file as a string.
230
+ */
231
+ toDecodedArray(decoder = new TextDecoder()) {
232
+ return Array.from(this, (bytes) => decoder.decode(bytes));
233
+ }
234
+ [Symbol.iterator]() {
235
+ return this;
236
+ }
237
+ }
238
+ //# sourceMappingURL=Spliterator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Spliterator.js","sourceRoot":"","sources":["../../lib/Spliterator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,gBAAgB,EAAyC,MAAM,uBAAuB,CAAA;AAC/F,OAAO,EAAE,iBAAiB,EAA0B,uBAAuB,EAAE,MAAM,wBAAwB,CAAA;AAC3G,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAG5C,OAAO,EA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AC;QACvB,OAAO,IAAI,CAAA;IACZ,CAAC"}
@@ -0,0 +1,40 @@
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 interface TextSpliteratorInit {
10
+ /**
11
+ * The encoding to use when decoding the data.
12
+ *
13
+ * @default "utf-8"
14
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder/TextDecoder
15
+ */
16
+ encoding?: string;
17
+ /**
18
+ * Whether to throw an error when encountering invalid data, or to swap it with a replacement
19
+ * character.
20
+ */
21
+ fatal?: boolean;
22
+ /**
23
+ * Whether to ignore BOM characters.
24
+ */
25
+ ignoreBOM?: boolean;
26
+ }
27
+ export declare abstract class TextSpliterator {
28
+ constructor();
29
+ /**
30
+ * @yields Each row as a string.
31
+ */
32
+ static from(source: CharacterSequenceInput, { encoding, fatal, ignoreBOM, ...options }?: TextSpliteratorInit & SpliteratorInit): Generator<string>;
33
+ /**
34
+ * Given a byte array or string, yield each row as an array of columns.
35
+ *
36
+ * @yields Each row as an array of columns.
37
+ */
38
+ static fromAsync(source: AsyncDataResource, { encoding, fatal, ignoreBOM, ...options }?: TextSpliteratorInit & AsyncSpliteratorInit): AsyncGenerator<string>;
39
+ }
40
+ //# sourceMappingURL=TextSpliterator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextSpliterator.d.ts","sourceRoot":"","sources":["../../lib/TextSpliterator.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,MAAM,WAAW,mBAAmB;IACnC;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IAEjB;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;IAEf;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,8BAAsB,eAAe;;IAKpC;;OAEG;IACH,MAAM,CAAE,IAAI,CACX,MAAM,EAAE,sBAAsB,EAC9B,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,OAAO,EAAE,GAAE,mBAAmB,GAAG,eAAoB,GACpF,SAAS,CAAC,MAAM,CAAC;IAwBpB;;;;OAIG;WACW,SAAS,CACtB,MAAM,EAAE,iBAAiB,EACzB,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,OAAO,EAAE,GAAE,mBAAmB,GAAG,oBAAyB,GACzF,cAAc,CAAC,MAAM,CAAC;CAsBzB"}
@@ -0,0 +1,56 @@
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 TextSpliterator {
8
+ constructor() {
9
+ throw new TypeError("Static class cannot be instantiated. Did you mean `TextSpliterator.from`?");
10
+ }
11
+ /**
12
+ * @yields Each row as a string.
13
+ */
14
+ static *from(source, { encoding, fatal, ignoreBOM, ...options } = {}) {
15
+ const decoder = new TextDecoder(encoding, { fatal, ignoreBOM });
16
+ let rowCursor = 0;
17
+ const spliterator = Spliterator.from(source, options);
18
+ for (const row of spliterator) {
19
+ let decoded;
20
+ try {
21
+ decoded = decoder.decode(row);
22
+ }
23
+ catch (parsedError) {
24
+ const error = SyntaxError(`Failed to decode data at row ${rowCursor}`);
25
+ error.cause = parsedError;
26
+ throw error;
27
+ }
28
+ yield decoded;
29
+ rowCursor++;
30
+ }
31
+ }
32
+ /**
33
+ * Given a byte array or string, yield each row as an array of columns.
34
+ *
35
+ * @yields Each row as an array of columns.
36
+ */
37
+ static async *fromAsync(source, { encoding, fatal, ignoreBOM, ...options } = {}) {
38
+ const decoder = new TextDecoder(encoding, { fatal, ignoreBOM });
39
+ let rowCursor = 0;
40
+ const spliterator = await Spliterator.fromAsync(source, options);
41
+ for await (const row of spliterator) {
42
+ let decoded;
43
+ try {
44
+ decoded = decoder.decode(row);
45
+ }
46
+ catch (parsedError) {
47
+ const error = SyntaxError(`Failed to decode data at row ${rowCursor}`);
48
+ error.cause = parsedError;
49
+ throw error;
50
+ }
51
+ yield decoded;
52
+ rowCursor++;
53
+ }
54
+ }
55
+ }
56
+ //# sourceMappingURL=TextSpliterator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextSpliterator.js","sourceRoot":"","sources":["../../lib/TextSpliterator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAwB,WAAW,EAAmB,MAAM,kBAAkB,CAAA;AAuBrF,MAAM,OAAgB,eAAe;IACpC;QACC,MAAM,IAAI,SAAS,CAAC,2EAA2E,CAAC,CAAA;IACjG,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,CAAC,IAAI,CACX,MAA8B,EAC9B,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,OAAO,KAA4C,EAAE;QAEtF,MAAM,OAAO,GAAG,IAAI,WAAW,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAA;QAC/D,IAAI,SAAS,GAAG,CAAC,CAAA;QAEjB,MAAM,WAAW,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;QAErD,KAAK,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;YAC/B,IAAI,OAAe,CAAA;YAEnB,IAAI,CAAC;gBACJ,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;YAC9B,CAAC;YAAC,OAAO,WAAW,EAAE,CAAC;gBACtB,MAAM,KAAK,GAAG,WAAW,CAAC,gCAAgC,SAAS,EAAE,CAAC,CAAA;gBACtE,KAAK,CAAC,KAAK,GAAG,WAAW,CAAA;gBAEzB,MAAM,KAAK,CAAA;YACZ,CAAC;YAED,MAAM,OAAO,CAAA;YAEb,SAAS,EAAE,CAAA;QACZ,CAAC;IACF,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,CACtB,MAAyB,EACzB,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,OAAO,KAAiD,EAAE;QAE3F,MAAM,OAAO,GAAG,IAAI,WAAW,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAA;QAC/D,IAAI,SAAS,GAAG,CAAC,CAAA;QACjB,MAAM,WAAW,GAAG,MAAM,WAAW,CAAC,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;QAEhE,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;YACrC,IAAI,OAAe,CAAA;YAEnB,IAAI,CAAC;gBACJ,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;YAC9B,CAAC;YAAC,OAAO,WAAW,EAAE,CAAC;gBACtB,MAAM,KAAK,GAAG,WAAW,CAAC,gCAAgC,SAAS,EAAE,CAAC,CAAA;gBACtE,KAAK,CAAC,KAAK,GAAG,WAAW,CAAA;gBAEzB,MAAM,KAAK,CAAA;YACZ,CAAC;YAED,MAAM,OAAO,CAAA;YAEb,SAAS,EAAE,CAAA;QACZ,CAAC;IACF,CAAC;CACD"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ */
6
+ import type { CamelCase, SnakeCase } from "type-fest";
7
+ /**
8
+ * Converts a name to snake_case, unless the name is already in all caps.
9
+ */
10
+ export declare function smartSnakeCase<T extends string>(name: T): T extends Uppercase<T> ? T : SnakeCase<T>;
11
+ /**
12
+ * Converts a name to camelCase, unless the name is already in all caps.
13
+ */
14
+ export declare function smartCamelCase<T extends string>(name: T): T extends Uppercase<T> ? T : CamelCase<T>;
15
+ /**
16
+ * Predicate to determine if a given string is uniformly cased, i.e. all uppercase or all lowercase.
17
+ */
18
+ export declare function isUniformlyCased(input: string | null): boolean;
19
+ /**
20
+ * Capitalizes a string, unless the string is uniformly cased, or an email address.
21
+ */
22
+ export declare function smartCapitalCase(input: string): string;
23
+ /**
24
+ * Given an array of column names, normalize them to ensure they are unique and usable as object
25
+ * keys.
26
+ */
27
+ export declare function normalizeColumnNames(columnHeaders: Iterable<string>): string[];
28
+ //# sourceMappingURL=casing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"casing.d.ts","sourceRoot":"","sources":["../../lib/casing.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAErD;;GAEG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,SAAS,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAiBnG;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,SAAS,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAInG;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAE9D;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAKtD;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,MAAM,EAAE,CAkB9E"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ */
6
+ import { camelCase, capitalCase, snakeCase } from "change-case";
7
+ /**
8
+ * Converts a name to snake_case, unless the name is already in all caps.
9
+ */
10
+ export function smartSnakeCase(name) {
11
+ const normalizedName = name
12
+ // Remove periods after capital letters, e.g. "U.S.A." -> "USA"
13
+ .replace(/([A-Z])(\.+)/g, "$1")
14
+ .trim();
15
+ if (normalizedName.toUpperCase() === normalizedName) {
16
+ return name
17
+ // Replace all non-word characters with underscores...
18
+ .replace(/\W{1,}/g, "_")
19
+ // ...and then replace all sequences of underscores with a single underscore.
20
+ .replace(/_{2,}/g, "_");
21
+ }
22
+ return snakeCase(normalizedName);
23
+ }
24
+ /**
25
+ * Converts a name to camelCase, unless the name is already in all caps.
26
+ */
27
+ export function smartCamelCase(name) {
28
+ if (name.toUpperCase() === name)
29
+ return name;
30
+ return camelCase(name);
31
+ }
32
+ /**
33
+ * Predicate to determine if a given string is uniformly cased, i.e. all uppercase or all lowercase.
34
+ */
35
+ export function isUniformlyCased(input) {
36
+ return Boolean(input && (input === input.toUpperCase() || input === input.toLowerCase()));
37
+ }
38
+ /**
39
+ * Capitalizes a string, unless the string is uniformly cased, or an email address.
40
+ */
41
+ export function smartCapitalCase(input) {
42
+ if (input.includes("@"))
43
+ return input;
44
+ if (isUniformlyCased(input))
45
+ return input;
46
+ return capitalCase(input);
47
+ }
48
+ /**
49
+ * Given an array of column names, normalize them to ensure they are unique and usable as object
50
+ * keys.
51
+ */
52
+ export function normalizeColumnNames(columnHeaders) {
53
+ const columnInputCountMap = new Map();
54
+ const distinctColumns = new Set();
55
+ const keyableColumnNames = Iterator.from(columnHeaders).map(smartSnakeCase);
56
+ for (const columnHeader of keyableColumnNames) {
57
+ if (distinctColumns.has(columnHeader)) {
58
+ const headerCount = (columnInputCountMap.get(columnHeader) ?? 1) + 1;
59
+ columnInputCountMap.set(columnHeader, headerCount);
60
+ const uniqueColumnName = `${columnHeader}_${headerCount}`;
61
+ distinctColumns.add(uniqueColumnName);
62
+ }
63
+ else {
64
+ distinctColumns.add(columnHeader);
65
+ }
66
+ }
67
+ return Array.from(distinctColumns);
68
+ }
69
+ //# sourceMappingURL=casing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"casing.js","sourceRoot":"","sources":["../../lib/casing.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAG/D;;GAEG;AACH,MAAM,UAAU,cAAc,CAAmB,IAAO;IACvD,MAAM,cAAc,GAAG,IAAI;QAC1B,+DAA+D;SAC9D,OAAO,CAAC,eAAe,EAAE,IAAI,CAAC;SAC9B,IAAI,EAAE,CAAA;IAER,IAAI,cAAc,CAAC,WAAW,EAAE,KAAK,cAAc,EAAE,CAAC;QACrD,OACC,IAAI;YACH,sDAAsD;aACrD,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC;YACxB,6EAA6E;aAC5E,OAAO,CAAC,QAAQ,EAAE,GAAG,CACvB,CAAA;IACF,CAAC;IAED,OAAO,SAAS,CAAC,cAAc,CAAQ,CAAA;AACxC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAmB,IAAO;IACvD,IAAI,IAAI,CAAC,WAAW,EAAE,KAAK,IAAI;QAAE,OAAO,IAAW,CAAA;IAEnD,OAAO,SAAS,CAAC,IAAI,CAAQ,CAAA;AAC9B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAoB;IACpD,OAAO,OAAO,CAAC,KAAK,IAAI,CAAC,KAAK,KAAK,KAAK,CAAC,WAAW,EAAE,IAAI,KAAK,KAAK,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAA;AAC1F,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC7C,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,KAAK,CAAA;IACrC,IAAI,gBAAgB,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAA;IAEzC,OAAO,WAAW,CAAC,KAAK,CAAC,CAAA;AAC1B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,aAA+B;IACnE,MAAM,mBAAmB,GAAG,IAAI,GAAG,EAAkB,CAAA;IACrD,MAAM,eAAe,GAAG,IAAI,GAAG,EAAU,CAAA;IACzC,MAAM,kBAAkB,GAAG,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA;IAE3E,KAAK,MAAM,YAAY,IAAI,kBAAkB,EAAE,CAAC;QAC/C,IAAI,eAAe,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC;YACvC,MAAM,WAAW,GAAG,CAAC,mBAAmB,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAA;YACpE,mBAAmB,CAAC,GAAG,CAAC,YAAY,EAAE,WAAW,CAAC,CAAA;YAElD,MAAM,gBAAgB,GAAG,GAAG,YAAY,IAAI,WAAW,EAAE,CAAA;YACzD,eAAe,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAA;QACtC,CAAC;aAAM,CAAC;YACP,eAAe,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;QAClC,CAAC;IACF,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;AACnC,CAAC"}
@@ -0,0 +1,98 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license AGPL-3.0
4
+ * @author Teffen Ellis, et al.
5
+ */
6
+ import { type PathLike } from "node:fs";
7
+ import { TypedArray } from "type-fest";
8
+ import { ByteRangeReader, ReadBytesOptions, StatsLike, TypedArrayFallback, type FileHandleLike, type FileResourceLike } from "../shared.js";
9
+ export interface NodeFileResourceInit {
10
+ name?: string;
11
+ type?: string;
12
+ position?: number;
13
+ byteLength?: number;
14
+ lastModified?: number;
15
+ blockSize?: number;
16
+ }
17
+ /**
18
+ * An isomorphic file resource which can be read from and disposed.
19
+ */
20
+ export declare class NodeFileResource implements FileResourceLike, ByteRangeReader, AsyncDisposable {
21
+ #private;
22
+ /**
23
+ * The last modified timestamp of the file.
24
+ */
25
+ readonly lastModified: number;
26
+ /**
27
+ * The name of the file.
28
+ */
29
+ readonly name: string;
30
+ /**
31
+ * @deprecated This property is not supported in Node.js.
32
+ */
33
+ readonly webkitRelativePath = "";
34
+ readonly blockSize?: number;
35
+ /**
36
+ * The byte length of the file.
37
+ */
38
+ readonly size: number;
39
+ /**
40
+ * The byte length of the file.
41
+ *
42
+ * Alias for {@linkcode #byteLength}.
43
+ */
44
+ get byteLength(): number;
45
+ readonly type: string;
46
+ constructor(handle: FileHandleLike, init: NodeFileResourceInit);
47
+ /**
48
+ * Read a range of bytes from the file.
49
+ *
50
+ * @param options - The options for reading the byte range.
51
+ */
52
+ read<B extends TypedArray>(options?: ReadBytesOptions & {
53
+ buffer?: B;
54
+ }): Promise<TypedArrayFallback<B>>;
55
+ /**
56
+ * Read the entire file as a byte array.
57
+ *
58
+ * @see {@linkcode slice} to create a sliced view of the file.
59
+ * @see {@linkcode arrayBuffer} to read the file as an array buffer.
60
+ */
61
+ bytes(): Promise<Uint8Array>;
62
+ /**
63
+ * Read the entire file as an array buffer.
64
+ *
65
+ * @see {@linkcode slice} to create a sliced view of the file.
66
+ * @see {@linkcode bytes} to read the file as a byte array.
67
+ */
68
+ arrayBuffer(): Promise<ArrayBuffer>;
69
+ /**
70
+ * Slice the file into a new file resource.
71
+ *
72
+ * Note that the slice is a view of the original file, thus we're really just creating a new file
73
+ * resource with a different byte range.
74
+ *
75
+ * @param start - The starting byte offset.
76
+ * @param end - The ending byte offset.
77
+ * @param contentType - The content type of the slice.
78
+ *
79
+ * @returns A new file resource representing the sliced view of the file.
80
+ */
81
+ slice(start?: number, end?: number, contentType?: string): NodeFileResource;
82
+ /**
83
+ * Read the entire file as a string.
84
+ */
85
+ text(): Promise<string>;
86
+ /**
87
+ * Create a readable stream of the file.
88
+ */
89
+ stream(): ReadableStream<Uint8Array>;
90
+ [Symbol.asyncDispose](): Promise<void>;
91
+ dispose(): Promise<void>;
92
+ /**
93
+ * Create a new file resource from a file handle or path.
94
+ */
95
+ static open(input: FileHandleLike | PathLike, stats?: StatsLike, init?: NodeFileResourceInit): Promise<NodeFileResource>;
96
+ }
97
+ export default NodeFileResource;
98
+ //# sourceMappingURL=fs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../../lib/node/fs.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAA0B,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAA;AAG/D,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACtC,OAAO,EACN,eAAe,EAEf,gBAAgB,EAChB,SAAS,EACT,kBAAkB,EAClB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,MAAM,cAAc,CAAA;AAErB,MAAM,WAAW,oBAAoB;IACpC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;CAClB;AAED;;GAEG;AACH,qBAAa,gBAAiB,YAAW,gBAAgB,EAAE,eAAe,EAAE,eAAe;;IAG1F;;OAEG;IACH,SAAgB,YAAY,EAAE,MAAM,CAAA;IACpC;;OAEG;IACH,SAAgB,IAAI,EAAE,MAAM,CAAA;IAC5B;;OAEG;IACH,SAAgB,kBAAkB,MAAK;IAEvC,SAAgB,SAAS,CAAC,EAAE,MAAM,CAAA;IAElC;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM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