spliterator 1.5.2 → 1.6.2

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 (68) hide show
  1. package/README.md +17 -1
  2. package/out/index.d.ts +0 -2
  3. package/out/index.d.ts.map +1 -1
  4. package/out/index.js +0 -2
  5. package/out/index.js.map +1 -1
  6. package/out/lib/AsyncSpliterator.d.ts +92 -11
  7. package/out/lib/AsyncSpliterator.d.ts.map +1 -1
  8. package/out/lib/AsyncSpliterator.js +153 -81
  9. package/out/lib/AsyncSpliterator.js.map +1 -1
  10. package/out/lib/BufferController.d.ts +12 -0
  11. package/out/lib/BufferController.d.ts.map +1 -1
  12. package/out/lib/BufferController.js +22 -0
  13. package/out/lib/BufferController.js.map +1 -1
  14. package/out/lib/CSVSpliterator.d.ts +30 -24
  15. package/out/lib/CSVSpliterator.d.ts.map +1 -1
  16. package/out/lib/CSVSpliterator.js +83 -33
  17. package/out/lib/CSVSpliterator.js.map +1 -1
  18. package/out/lib/CharacterSequence.d.ts +5 -15
  19. package/out/lib/CharacterSequence.d.ts.map +1 -1
  20. package/out/lib/CharacterSequence.js +15 -49
  21. package/out/lib/CharacterSequence.js.map +1 -1
  22. package/out/lib/JSONSpliterator.js +1 -1
  23. package/out/lib/JSONSpliterator.js.map +1 -1
  24. package/out/lib/SlidingWindow.d.ts +1 -47
  25. package/out/lib/SlidingWindow.d.ts.map +1 -1
  26. package/out/lib/SlidingWindow.js +0 -114
  27. package/out/lib/SlidingWindow.js.map +1 -1
  28. package/out/lib/Spliterator.d.ts +55 -5
  29. package/out/lib/Spliterator.d.ts.map +1 -1
  30. package/out/lib/Spliterator.js +138 -41
  31. package/out/lib/Spliterator.js.map +1 -1
  32. package/out/lib/shared.d.ts +21 -9
  33. package/out/lib/shared.d.ts.map +1 -1
  34. package/out/lib/shared.js +6 -6
  35. package/out/lib/shared.js.map +1 -1
  36. package/out/node/cli/commands/csv.d.ts +44 -0
  37. package/out/node/cli/commands/csv.d.ts.map +1 -0
  38. package/out/node/cli/commands/csv.js +78 -0
  39. package/out/node/cli/commands/csv.js.map +1 -0
  40. package/out/node/cli/commands/iterate.d.ts +37 -0
  41. package/out/node/cli/commands/iterate.d.ts.map +1 -0
  42. package/out/node/cli/commands/iterate.js +54 -0
  43. package/out/node/cli/commands/iterate.js.map +1 -0
  44. package/out/node/cli/index.d.ts +9 -0
  45. package/out/node/cli/index.d.ts.map +1 -0
  46. package/out/node/cli/index.js +34 -0
  47. package/out/node/cli/index.js.map +1 -0
  48. package/out/node/cli/utils.d.ts +52 -0
  49. package/out/node/cli/utils.d.ts.map +1 -0
  50. package/out/node/cli/utils.js +70 -0
  51. package/out/node/cli/utils.js.map +1 -0
  52. package/out/node/fs/index.d.ts +58 -0
  53. package/out/node/fs/index.d.ts.map +1 -0
  54. package/out/node/fs/index.js +142 -0
  55. package/out/node/fs/index.js.map +1 -0
  56. package/package.json +10 -5
  57. package/out/lib/DelimitedChunkReader.d.ts +0 -67
  58. package/out/lib/DelimitedChunkReader.d.ts.map +0 -1
  59. package/out/lib/DelimitedChunkReader.js +0 -113
  60. package/out/lib/DelimitedChunkReader.js.map +0 -1
  61. package/out/lib/DelimiterTransformer.d.ts +0 -27
  62. package/out/lib/DelimiterTransformer.d.ts.map +0 -1
  63. package/out/lib/DelimiterTransformer.js +0 -26
  64. package/out/lib/DelimiterTransformer.js.map +0 -1
  65. package/out/lib/node/fs.d.ts +0 -98
  66. package/out/lib/node/fs.d.ts.map +0 -1
  67. package/out/lib/node/fs.js +0 -162
  68. package/out/lib/node/fs.js.map +0 -1
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "spliterator",
3
- "version": "1.5.2",
4
- "description": "Line-delimited file utilities",
3
+ "version": "1.6.2",
4
+ "description": "Line-delimited iterator library for CSV, NDJSON, and other delimited formats.",
5
5
  "keywords": [
6
6
  "csv",
7
7
  "ndjson",
@@ -29,15 +29,18 @@
29
29
  "exports": {
30
30
  "./package.json": "./package.json",
31
31
  ".": "./out/index.js",
32
- "./node/fs": "./out/lib/node/fs.js",
32
+ "./node/fs": "./out/node/fs/index.js",
33
33
  "./test/utils": "./out/test/utils.js"
34
34
  },
35
+ "bin": "./out/node/cli/index.js",
35
36
  "files": [
36
37
  "out/index.d.ts",
37
38
  "out/index.d.ts.map",
38
39
  "out/index.js.map",
39
40
  "out/index.js",
40
- "out/lib/**/*"
41
+ "out/lib/**/*",
42
+ "out/node/**/*",
43
+ "out/cli/**/*"
41
44
  ],
42
45
  "scripts": {
43
46
  "demo": "node out/examples/simple-iteration.js",
@@ -54,13 +57,15 @@
54
57
  },
55
58
  "prettier": "@sister.software/prettier-config",
56
59
  "dependencies": {
57
- "change-case": "^5.4.4"
60
+ "change-case": "^5.4.4",
61
+ "yargs": "^17.2.1"
58
62
  },
59
63
  "devDependencies": {
60
64
  "@sister.software/eslint-config": "7.1.3",
61
65
  "@sister.software/prettier-config": "7.1.3",
62
66
  "@sister.software/tsconfig": "7.1.3",
63
67
  "@types/node": "^22.10.2",
68
+ "@types/yargs": "^17.0.33",
64
69
  "colorette": "^2.0.20",
65
70
  "eslint": "^9.13.0",
66
71
  "eslint-config-prettier": "^9.1.0",
@@ -1,67 +0,0 @@
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, ByteRange } from "./shared.js";
8
- /**
9
- * Options for the delimited chunk reader.
10
- */
11
- export interface DeliminatedChunkReaderInit {
12
- /**
13
- * The desired number of chunks. This is a target, not a guarantee.
14
- *
15
- * This will never be less than 1, nor greater than the number of delimiters in the file, nor
16
- * greater than the byte length of the file.
17
- */
18
- chunks?: number;
19
- /**
20
- * The character to delimit by. Typically a newline or comma.
21
- */
22
- delimiter?: CharacterSequenceInput;
23
- /**
24
- * Whether to close the file handle after reading.
25
- */
26
- autoClose?: boolean;
27
- /**
28
- * The limit of bytes to read from the file.
29
- */
30
- limit?: number;
31
- }
32
- /**
33
- * Given a file handle containing delimited data and a desired slice count, returns an array of
34
- * slices of the buffer between delimiters.
35
- *
36
- * This is an advanced function so an analogy is provided:
37
- *
38
- * Suppose you had to manually search through a very large book page by page to find where each
39
- * chapter begins and ends. For a book with 1,000,000 pages, a single person would take a long time
40
- * to go through it all.
41
- *
42
- * You could add more people to the task by laying out all the pages, measuring the length and
43
- * assigning each person a length of pages to traverse.
44
- *
45
- * There's a few ways to go about this:
46
- *
47
- * We could approach this in serial -- having the first worker start from page 1 and scanning until
48
- * they find the beginning of the next chapter, handing off the range to the next worker. This is
49
- * how `AsyncSlidingWindow` approaches the problem.
50
- *
51
- * However this is inefficient because no matter how many workers we have, they must wait for the
52
- * previous worker to finish before they can start. Ideally, a desired number of workers would be
53
- * able to scan their own _length_ of pages simultaneously, and settle up on the boundaries of the
54
- * chapters they find.
55
- *
56
- * `DeliminatedChunkReader` is like the second approach. Given a desired number of chunks
57
- *
58
- * @returns A contiguous array of slices of the buffer separated by a delimiter.
59
- */
60
- export declare class DelimitedChunkReader {
61
- static fromAsync(
62
- /**
63
- * The buffer containing newline-delimited data.
64
- */
65
- source: AsyncDataResource, init?: DeliminatedChunkReaderInit): Promise<ByteRange[]>;
66
- }
67
- //# sourceMappingURL=DelimitedChunkReader.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DelimitedChunkReader.d.ts","sourceRoot":"","sources":["../../lib/DelimitedChunkReader.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAqB,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AAClF,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAwC,MAAM,aAAa,CAAA;AAGhG;;GAEG;AACH,MAAM,WAAW,0BAA0B;IAC1C;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IAEf;;OAEG;IACH,SAAS,CAAC,EAAE,sBAAsB,CAAA;IAElC;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;IAEnB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;CACd;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,qBAAa,oBAAoB;WACnB,SAAS;IACrB;;OAEG;IACH,MAAM,EAAE,iBAAiB,EACzB,IAAI,GAAE,0BAA+B,GACnC,OAAO,CAAC,SAAS,EAAE,CAAC;CAyFvB"}
@@ -1,113 +0,0 @@
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 { isFileResourceLike } from "./shared.js";
8
- import { AsyncSlidingWindow } from "./SlidingWindow.js";
9
- /**
10
- * Given a file handle containing delimited data and a desired slice count, returns an array of
11
- * slices of the buffer between delimiters.
12
- *
13
- * This is an advanced function so an analogy is provided:
14
- *
15
- * Suppose you had to manually search through a very large book page by page to find where each
16
- * chapter begins and ends. For a book with 1,000,000 pages, a single person would take a long time
17
- * to go through it all.
18
- *
19
- * You could add more people to the task by laying out all the pages, measuring the length and
20
- * assigning each person a length of pages to traverse.
21
- *
22
- * There's a few ways to go about this:
23
- *
24
- * We could approach this in serial -- having the first worker start from page 1 and scanning until
25
- * they find the beginning of the next chapter, handing off the range to the next worker. This is
26
- * how `AsyncSlidingWindow` approaches the problem.
27
- *
28
- * However this is inefficient because no matter how many workers we have, they must wait for the
29
- * previous worker to finish before they can start. Ideally, a desired number of workers would be
30
- * able to scan their own _length_ of pages simultaneously, and settle up on the boundaries of the
31
- * chapters they find.
32
- *
33
- * `DeliminatedChunkReader` is like the second approach. Given a desired number of chunks
34
- *
35
- * @returns A contiguous array of slices of the buffer separated by a delimiter.
36
- */
37
- export class DelimitedChunkReader {
38
- static async fromAsync(
39
- /**
40
- * The buffer containing newline-delimited data.
41
- */
42
- source, init = {}) {
43
- let file;
44
- if (isFileResourceLike(source)) {
45
- file = source;
46
- }
47
- else {
48
- const { NodeFileResource } = await import("spliterator/node/fs");
49
- file = await NodeFileResource.open(source);
50
- }
51
- const byteLimit = init.limit ?? file.size;
52
- // const byteLimit = init.limit ?? (await fileHandle.stat()).size
53
- const delimiter = new CharacterSequence(init.delimiter);
54
- const delimiterLength = delimiter.length;
55
- const desiredSlices = Math.min(Math.max(1, init.chunks ?? 2), byteLimit / delimiterLength, byteLimit);
56
- const fallback = [[0, byteLimit]];
57
- if (desiredSlices === 1) {
58
- return fallback;
59
- }
60
- const ranges = [];
61
- const chunkSize = Math.floor(byteLimit / desiredSlices);
62
- for (let i = 0; i < desiredSlices; i++) {
63
- const previousSlice = ranges[i - 1] ?? [0, 0];
64
- const chunkEnd = Math.min(i * chunkSize, byteLimit);
65
- const searchStart = Math.max(chunkEnd - delimiterLength * 2, previousSlice[1]);
66
- const searchEnd = Math.min(chunkEnd + delimiterLength * 2, byteLimit);
67
- const reverse = new AsyncSlidingWindow(file, {
68
- delimiter,
69
- position: searchStart,
70
- byteLength: searchEnd,
71
- });
72
- const forward = new AsyncSlidingWindow(file, {
73
- delimiter,
74
- position: searchStart,
75
- byteLength: searchEnd,
76
- });
77
- const [previousRange, nextRange] = await Promise.all([
78
- // We look backward to find the previous delimiter at a midpoint in the chunk...
79
- reverse.previous(),
80
- // And forward to find the next delimiter.
81
- forward.next(),
82
- ]);
83
- if (i === 0) {
84
- // The first slice is always from the beginning of the file to the first delimiter.
85
- ranges.push(nextRange.value);
86
- continue;
87
- }
88
- if (previousRange.done || nextRange.done)
89
- break;
90
- if (i === desiredSlices - 1) {
91
- const range = [previousRange.value[0] + delimiterLength, byteLimit];
92
- // We need to fix the previous slice to end at the previous delimiter.
93
- previousSlice[1] = previousRange.value[0] - delimiterLength;
94
- // The last slice is always from the last delimiter to the end of the file.
95
- ranges.push(range);
96
- break;
97
- }
98
- // We need to fix the previous slice to end at the previous delimiter.
99
- previousSlice[1] = previousRange.value[0] - delimiterLength;
100
- // And we need to fix the current slice to start at the previous delimiter.
101
- nextRange.value[0] = previousRange.value[0] + delimiterLength;
102
- // We can now add the current slice to the list.
103
- ranges.push(nextRange.value);
104
- }
105
- if (!ranges.length)
106
- return fallback;
107
- if (init.autoClose) {
108
- await file[Symbol.asyncDispose]?.();
109
- }
110
- return ranges;
111
- }
112
- }
113
- //# sourceMappingURL=DelimitedChunkReader.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DelimitedChunkReader.js","sourceRoot":"","sources":["../../lib/DelimitedChunkReader.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,iBAAiB,EAA0B,MAAM,wBAAwB,CAAA;AAClF,OAAO,EAAkD,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAChG,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AA8BvD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,OAAO,oBAAoB;IAChC,MAAM,CAAC,KAAK,CAAC,SAAS;IACrB;;OAEG;IACH,MAAyB,EACzB,OAAmC,EAAE;QAErC,IAAI,IAAsB,CAAA;QAE1B,IAAI,kBAAkB,CAAC,MAAM,CAAC,EAAE,CAAC;YAChC,IAAI,GAAG,MAAM,CAAA;QACd,CAAC;aAAM,CAAC;YACP,MAAM,EAAE,gBAAgB,EAAE,GAAG,MAAM,MAAM,CAAC,qBAAqB,CAAC,CAAA;YAChE,IAAI,GAAG,MAAM,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAC3C,CAAC;QAED,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI,CAAA;QACzC,iEAAiE;QAEjE,MAAM,SAAS,GAAG,IAAI,iBAAiB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;QACvD,MAAM,eAAe,GAAG,SAAS,CAAC,MAAM,CAAA;QAExC,MAAM,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,I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
3
- * @license AGPL-3.0
4
- * @author Teffen Ellis, et al.
5
- */
6
- import { CharacterSequenceInput } from "./CharacterSequence.js";
7
- import { TypedArray } from "./shared.js";
8
- /**
9
- * Options for the `DelimiterTransformer` class.
10
- */
11
- export interface DelimiterTransformerOptions {
12
- /**
13
- * The delimiter to use when splitting fields.
14
- *
15
- * @default `Delimiter.Comma`
16
- */
17
- delimiter?: CharacterSequenceInput;
18
- }
19
- /**
20
- * A transform stream that splits incoming text into fields using a delimiter.
21
- *
22
- * This is useful for parsing CSV files, for example.
23
- */
24
- export declare class DelimiterTransformer<T extends TypedArray = TypedArray> extends TransformStream<T, T[]> {
25
- constructor(options?: DelimiterTransformerOptions);
26
- }
27
- //# sourceMappingURL=DelimiterTransformer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DelimiterTransformer.d.ts","sourceRoot":"","sources":["../../lib/DelimiterTransformer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAqB,sBAAsB,EAA6B,MAAM,wBAAwB,CAAA;AAC7G,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExC;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC3C;;;;OAIG;IACH,SAAS,CAAC,EAAE,sBAAsB,CAAA;CAClC;AAED;;;;GAIG;AACH,qBAAa,oBAAoB,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU,CAAE,SAAQ,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;gBACvF,OAAO,GAAE,2BAAgC;CAerD"}
@@ -1,26 +0,0 @@
1
- /**
2
- * @copyright Sister Software
3
- * @license AGPL-3.0
4
- * @author Teffen Ellis, et al.
5
- */
6
- import { CharacterSequence, Delimiters, takeDelimited } from "./CharacterSequence.js";
7
- /**
8
- * A transform stream that splits incoming text into fields using a delimiter.
9
- *
10
- * This is useful for parsing CSV files, for example.
11
- */
12
- export class DelimiterTransformer extends TransformStream {
13
- constructor(options = {}) {
14
- const delimiter = new CharacterSequence(options.delimiter ?? Delimiters.Comma);
15
- super({
16
- transform: (line, controller) => {
17
- if (line.length === 0) {
18
- return;
19
- }
20
- const columns = Array.from(takeDelimited(line, delimiter));
21
- controller.enqueue(columns);
22
- },
23
- });
24
- }
25
- }
26
- //# sourceMappingURL=DelimiterTransformer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DelimiterTransformer.js","sourceRoot":"","sources":["../../lib/DelimiterTransformer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,iBAAiB,EAA0B,UAAU,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAe7G;;;;GAIG;AACH,MAAM,OAAO,oBAAwD,SAAQ,eAAuB;IACnG,YAAY,UAAuC,EAAE;QACpD,MAAM,SAAS,GAAG,IAAI,iBAAiB,CAAC,OAAO,CAAC,SAAS,IAAI,UAAU,CAAC,KAAK,CAAC,CAAA;QAE9E,KAAK,CAAC;YACL,SAAS,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE;gBAC/B,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;oBACvB,OAAM;gBACP,CAAC;gBAED,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAA;gBAE1D,UAAU,CAAC,OAAO,CAAC,OAAyB,CAAC,CAAA;YAC9C,CAAC;SACD,CAAC,CAAA;IACH,CAAC;CACD"}
@@ -1,98 +0,0 @@
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
@@ -1 +0,0 @@
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,CAAA;IAErB;;;;OAIG;IACH,IAAW,UAAU,IAAI,MAAM,CAE9B;IAMD,SAAgB,IAAI,EAAE,MAAM,CAAA;gBAEhB,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,oBAAoB;IAW9D;;;;OAIG;IACG,IAAI,CAAC,CAAC,SAAS,UAAU,EAAE,OAAO,GAAE,gBAAgB,GAAG;QAAE,MAAM,CAAC,EAAE,CAAC,CAAA;KAAO,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;IAwBjH;;;;;OAKG;IACU,KAAK,IAAI,OAAO,CAAC,UAAU,CAAC;IAIzC;;;;;OAKG;IACI,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC;IAI1C;;;;;;;;;;;OAWG;IACI,KAAK,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,gBAAgB;IAelF;;OAEG;IACU,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC;IAOpC;;OAEG;IACI,MAAM,IAAI,cAAc,CAAC,UAAU,CAAC;IAI9B,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5C,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAI/B;;OAEG;WACU,IAAI,CAChB,KAAK,EAAE,cAAc,GAAG,QAAQ,EAChC,KAAK,CAAC,EAAE,SAAS,EACjB,IAAI,GAAE,oBAAyB,GAC7B,OAAO,CAAC,gBAAgB,CAAC;CAqB5B;AAED,eAAe,gBAAgB,CAAA"}
@@ -1,162 +0,0 @@
1
- /**
2
- * @copyright Sister Software
3
- * @license AGPL-3.0
4
- * @author Teffen Ellis, et al.
5
- */
6
- import { read } from "node:fs";
7
- import { open } from "node:fs/promises";
8
- import * as path from "node:path";
9
- import { isFileHandleLike, } from "../shared.js";
10
- /**
11
- * An isomorphic file resource which can be read from and disposed.
12
- */
13
- export class NodeFileResource {
14
- #handle;
15
- /**
16
- * The last modified timestamp of the file.
17
- */
18
- lastModified;
19
- /**
20
- * The name of the file.
21
- */
22
- name;
23
- /**
24
- * @deprecated This property is not supported in Node.js.
25
- */
26
- webkitRelativePath = "";
27
- blockSize;
28
- /**
29
- * The byte length of the file.
30
- */
31
- size;
32
- /**
33
- * The byte length of the file.
34
- *
35
- * Alias for {@linkcode #byteLength}.
36
- */
37
- get byteLength() {
38
- return this.size;
39
- }
40
- /**
41
- * The byte position of the file.
42
- */
43
- #position;
44
- type;
45
- constructor(handle, init) {
46
- this.#handle = handle;
47
- this.lastModified = init.lastModified ?? Date.now();
48
- this.name = init.name ?? "";
49
- this.#position = init.position ?? 0;
50
- this.size = (init.byteLength ?? 0) - this.#position;
51
- this.blockSize = init.blockSize;
52
- this.type = init.type ?? "";
53
- }
54
- /**
55
- * Read a range of bytes from the file.
56
- *
57
- * @param options - The options for reading the byte range.
58
- */
59
- async read(options = {}) {
60
- const byteLength = options.length ?? this.size;
61
- const offset = options.offset ?? 0;
62
- const buffer = (options.buffer ?? new Uint8Array(byteLength));
63
- const position = options.position ?? this.#position;
64
- await new Promise((resolve, reject) => read(this.#handle.fd, {
65
- buffer,
66
- offset,
67
- position,
68
- }, (error) => {
69
- if (error)
70
- reject(error);
71
- else
72
- resolve();
73
- }));
74
- return buffer;
75
- }
76
- /**
77
- * Read the entire file as a byte array.
78
- *
79
- * @see {@linkcode slice} to create a sliced view of the file.
80
- * @see {@linkcode arrayBuffer} to read the file as an array buffer.
81
- */
82
- async bytes() {
83
- return this.read();
84
- }
85
- /**
86
- * Read the entire file as an array buffer.
87
- *
88
- * @see {@linkcode slice} to create a sliced view of the file.
89
- * @see {@linkcode bytes} to read the file as a byte array.
90
- */
91
- arrayBuffer() {
92
- return this.bytes().then((bytes) => bytes.buffer);
93
- }
94
- /**
95
- * Slice the file into a new file resource.
96
- *
97
- * Note that the slice is a view of the original file, thus we're really just creating a new file
98
- * resource with a different byte range.
99
- *
100
- * @param start - The starting byte offset.
101
- * @param end - The ending byte offset.
102
- * @param contentType - The content type of the slice.
103
- *
104
- * @returns A new file resource representing the sliced view of the file.
105
- */
106
- slice(start, end, contentType) {
107
- start = start ?? 0;
108
- end = end ?? this.size;
109
- const byteLength = Math.max(0, end - start);
110
- return new NodeFileResource(this.#handle, {
111
- name: this.name,
112
- type: contentType ?? this.type,
113
- position: this.#position + start,
114
- byteLength,
115
- lastModified: this.lastModified,
116
- });
117
- }
118
- /**
119
- * Read the entire file as a string.
120
- */
121
- async text() {
122
- const buffer = await this.bytes();
123
- const decoder = new TextDecoder();
124
- return decoder.decode(buffer);
125
- }
126
- /**
127
- * Create a readable stream of the file.
128
- */
129
- stream() {
130
- return this.#handle.readableWebStream();
131
- }
132
- async [Symbol.asyncDispose]() {
133
- return this.#handle.close();
134
- }
135
- dispose() {
136
- return this.#handle.close();
137
- }
138
- /**
139
- * Create a new file resource from a file handle or path.
140
- */
141
- static async open(input, stats, init = {}) {
142
- let handle;
143
- let name = "";
144
- if (isFileHandleLike(input)) {
145
- handle = input;
146
- }
147
- else {
148
- handle = await open(input, "r");
149
- name = (init.name ?? typeof init.name === "string") ? init.name : path.basename(input.toString());
150
- }
151
- stats = stats ?? (await handle.stat());
152
- return new NodeFileResource(handle, {
153
- lastModified: stats.mtimeMs,
154
- byteLength: stats.size,
155
- ...init,
156
- name,
157
- blockSize: stats.blksize,
158
- });
159
- }
160
- }
161
- export default NodeFileResource;
162
- //# sourceMappingURL=fs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fs.js","sourceRoot":"","sources":["../../../lib/node/fs.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,IAAI,EAAmC,MAAM,SAAS,CAAA;AAC/D,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AAEjC,OAAO,EAEN,gBAAgB,GAMhB,MAAM,cAAc,CAAA;AAWrB;;GAEG;AACH,MAAM,OAAO,gBAAgB;IACnB,OAAO,CAAgB;IAEhC;;OAEG;IACa,YAAY,CAAQ;IACpC;;OAEG;IACa,IAAI,CAAQ;IAC5B;;OAEG;IACa,kBAAkB,GAAG,EAAE,CAAA;IAEvB,S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