spliterator 5.0.0 → 6.0.1

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 (61) hide show
  1. package/README.md +56 -0
  2. package/out/index.d.ts +7 -1
  3. package/out/index.d.ts.map +1 -1
  4. package/out/index.js +7 -1
  5. package/out/index.js.map +1 -1
  6. package/out/lib/AsyncSequence.d.ts +180 -0
  7. package/out/lib/AsyncSequence.d.ts.map +1 -0
  8. package/out/lib/AsyncSequence.js +432 -0
  9. package/out/lib/AsyncSequence.js.map +1 -0
  10. package/out/lib/AsyncSpliterator.d.ts +4 -2
  11. package/out/lib/AsyncSpliterator.d.ts.map +1 -1
  12. package/out/lib/AsyncSpliterator.js.map +1 -1
  13. package/out/lib/CSVSpliterator.d.ts +6 -5
  14. package/out/lib/CSVSpliterator.d.ts.map +1 -1
  15. package/out/lib/CSVSpliterator.js +46 -37
  16. package/out/lib/CSVSpliterator.js.map +1 -1
  17. package/out/lib/JSONSpliterator.d.ts +23 -11
  18. package/out/lib/JSONSpliterator.d.ts.map +1 -1
  19. package/out/lib/JSONSpliterator.js +28 -19
  20. package/out/lib/JSONSpliterator.js.map +1 -1
  21. package/out/lib/TextSpliterator.d.ts +4 -2
  22. package/out/lib/TextSpliterator.d.ts.map +1 -1
  23. package/out/lib/TextSpliterator.js +8 -9
  24. package/out/lib/TextSpliterator.js.map +1 -1
  25. package/out/lib/adaptive-source.d.ts +39 -0
  26. package/out/lib/adaptive-source.d.ts.map +1 -0
  27. package/out/lib/adaptive-source.js +95 -0
  28. package/out/lib/adaptive-source.js.map +1 -0
  29. package/out/lib/chunks.d.ts +20 -0
  30. package/out/lib/chunks.d.ts.map +1 -0
  31. package/out/lib/chunks.js +36 -0
  32. package/out/lib/chunks.js.map +1 -0
  33. package/out/lib/parallel-map-workers.d.ts +57 -0
  34. package/out/lib/parallel-map-workers.d.ts.map +1 -0
  35. package/out/lib/parallel-map-workers.js +82 -0
  36. package/out/lib/parallel-map-workers.js.map +1 -0
  37. package/out/lib/parallel-map.d.ts +17 -42
  38. package/out/lib/parallel-map.d.ts.map +1 -1
  39. package/out/lib/parallel-map.js +18 -66
  40. package/out/lib/parallel-map.js.map +1 -1
  41. package/out/lib/pivot.d.ts +30 -0
  42. package/out/lib/pivot.d.ts.map +1 -0
  43. package/out/lib/pivot.js +47 -0
  44. package/out/lib/pivot.js.map +1 -0
  45. package/out/lib/shared.d.ts +0 -27
  46. package/out/lib/shared.d.ts.map +1 -1
  47. package/out/lib/shared.js +0 -53
  48. package/out/lib/shared.js.map +1 -1
  49. package/out/lib/take.d.ts +16 -0
  50. package/out/lib/take.d.ts.map +1 -1
  51. package/out/lib/take.js +28 -0
  52. package/out/lib/take.js.map +1 -1
  53. package/out/lib/utils.d.ts +37 -0
  54. package/out/lib/utils.d.ts.map +1 -0
  55. package/out/lib/utils.js +39 -0
  56. package/out/lib/utils.js.map +1 -0
  57. package/out/lib/zip.d.ts +33 -0
  58. package/out/lib/zip.d.ts.map +1 -0
  59. package/out/lib/zip.js +59 -0
  60. package/out/lib/zip.js.map +1 -0
  61. package/package.json +6 -6
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license MIT
4
+ * @author Teffen Ellis, et al.
5
+ */
6
+ /**
7
+ * Convenience function to await an async iterable.
8
+ */
9
+ export declare function iterateInParallel<T>(asyncIterable: AsyncIterable<T>): Promise<void>;
10
+ /**
11
+ * Type-predicate for checking if a value is iterable.
12
+ *
13
+ * @category Type Guard
14
+ * @category Object
15
+ */
16
+ export declare function isIterable<T>(input: unknown): input is Iterable<T>;
17
+ /**
18
+ * Iterable that can be checked for the existence of a member.
19
+ */
20
+ export interface IndexedIterable<T = unknown> extends Iterable<T> {
21
+ has(value: T): boolean;
22
+ }
23
+ /**
24
+ * Type-predicate for checking if an member within an iterable can be checked for existence.
25
+ */
26
+ export declare function isIndexedIterable<T>(value: Iterable<T>): value is IndexedIterable<T>;
27
+ /**
28
+ * Extracts the property keys of an object that are of type `number`.
29
+ */
30
+ export type NumericProperties<T> = {
31
+ [K in keyof T]: T[K] extends number ? K : never;
32
+ }[keyof T];
33
+ /**
34
+ * Given an iterable of objects, returns the sum of the specified property.
35
+ */
36
+ export declare function sumOf<T extends object>(iterable: Iterable<T>, prop: NumericProperties<T>): number;
37
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../lib/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,wBAAsB,iBAAiB,CAAC,CAAC,EAAE,aAAa,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAIzF;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ,CAAC,CAAC,CAAC,CAElE;AAED;;GAEG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC,GAAG,OAAO,CAAE,SAAQ,QAAQ,CAAC,CAAC,CAAC;IAChE,GAAG,CAAC,KAAK,EAAE,CAAC,GAAG,OAAO,CAAA;CACtB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,eAAe,CAAC,CAAC,CAAC,CAEpF;AAED;;GAEG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI;KACjC,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,GAAG,CAAC,GAAG,KAAK;CAC/C,CAAC,MAAM,CAAC,CAAC,CAAA;AAEV;;GAEG;AACH,wBAAgB,KAAK,CAAC,CAAC,SAAS,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,MAAM,CAQjG"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license MIT
4
+ * @author Teffen Ellis, et al.
5
+ */
6
+ /**
7
+ * Convenience function to await an async iterable.
8
+ */
9
+ export async function iterateInParallel(asyncIterable) {
10
+ for await (const _ of asyncIterable) {
11
+ /* empty */
12
+ }
13
+ }
14
+ /**
15
+ * Type-predicate for checking if a value is iterable.
16
+ *
17
+ * @category Type Guard
18
+ * @category Object
19
+ */
20
+ export function isIterable(input) {
21
+ return Symbol.iterator in new Object(input);
22
+ }
23
+ /**
24
+ * Type-predicate for checking if an member within an iterable can be checked for existence.
25
+ */
26
+ export function isIndexedIterable(value) {
27
+ return value && typeof value.has === "function";
28
+ }
29
+ /**
30
+ * Given an iterable of objects, returns the sum of the specified property.
31
+ */
32
+ export function sumOf(iterable, prop) {
33
+ let total = 0;
34
+ for (const item of iterable) {
35
+ total += item[prop];
36
+ }
37
+ return total;
38
+ }
39
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../lib/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAI,aAA+B;IACzE,IAAI,KAAK,EAAE,MAAM,CAAC,IAAI,aAAa,EAAE,CAAC;QACrC,WAAW;IACZ,CAAC;AACF,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAI,KAAc;IAC3C,OAAO,MAAM,CAAC,QAAQ,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,CAAA;AAC5C,CAAC;AASD;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAI,KAAkB;IACtD,OAAO,KAAK,IAAI,OAAQ,KAAyB,CAAC,GAAG,KAAK,UAAU,CAAA;AACrE,CAAC;AASD;;GAEG;AACH,MAAM,UAAU,KAAK,CAAmB,QAAqB,EAAE,IAA0B;IACxF,IAAI,KAAK,GAAG,CAAC,CAAA;IAEb,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;QAC7B,KAAK,IAAI,IAAI,CAAC,IAAI,CAAW,CAAA;IAC9B,CAAC;IAED,OAAO,KAAK,CAAA;AACb,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license MIT
4
+ * @author Teffen Ellis, et al.
5
+ */
6
+ export type Zipped<T, U> = [a: T | undefined, b: U | undefined, idx: number];
7
+ export type ZippedEntries<Z> = Z extends Zipped<infer T, infer U> ? [T, U] : never;
8
+ export declare function zippedEntries<T, U>(zipped: Zipped<T, U>): ZippedEntries<Zipped<T, U>>;
9
+ /**
10
+ * Given two iterables, zip them together into a single iterable which yields pairs of elements.
11
+ *
12
+ * If one iterable is longer than the other, the shorter iterable will be padded with `undefined`.
13
+ *
14
+ * @param a The first iterable to zip.
15
+ * @param b The second iterable to zip.
16
+ *
17
+ * @yields Pairs of elements from the two iterables.
18
+ * @see {@linkcode zipAsync} for the asynchronous version.
19
+ */
20
+ export declare function zipSync<T, U>(a: Iterable<T>, b: Iterable<U>): Generator<Zipped<T, U>>;
21
+ /**
22
+ * Given two iterables, zip them together into a single iterable which yields pairs of elements.
23
+ *
24
+ * If one iterable is longer than the other, the shorter iterable will be padded with `undefined`.
25
+ *
26
+ * @param a The first iterable to zip.
27
+ * @param b The second iterable to zip.
28
+ *
29
+ * @yields Pairs of elements from the two iterables.
30
+ * @see {@linkcode zipSync} for the synchronous version.
31
+ */
32
+ export declare function zipAsync<T, U>(a: AsyncIterable<T> | Iterable<T>, b: AsyncIterable<U> | Iterable<U>): AsyncGenerator<[a: T | undefined, b: U | undefined, idx: number]>;
33
+ //# sourceMappingURL=zip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zip.d.ts","sourceRoot":"","sources":["../../lib/zip.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,MAAM,MAAM,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,GAAG,SAAS,EAAE,CAAC,EAAE,CAAC,GAAG,SAAS,EAAE,GAAG,EAAE,MAAM,CAAC,CAAA;AAE5E,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK,CAAA;AAElF,wBAAgB,aAAa,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAErF;AAED;;;;;;;;;;GAUG;AACH,wBAAiB,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAkBtF;AAED;;;;;;;;;;GAUG;AACH,wBAAuB,QAAQ,CAAC,CAAC,EAAE,CAAC,EACnC,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,EACjC,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,GAC/B,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,SAAS,EAAE,CAAC,EAAE,CAAC,GAAG,SAAS,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC,CAkBnE"}
package/out/lib/zip.js ADDED
@@ -0,0 +1,59 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license MIT
4
+ * @author Teffen Ellis, et al.
5
+ */
6
+ export function zippedEntries(zipped) {
7
+ return zipped.slice(0, 2);
8
+ }
9
+ /**
10
+ * Given two iterables, zip them together into a single iterable which yields pairs of elements.
11
+ *
12
+ * If one iterable is longer than the other, the shorter iterable will be padded with `undefined`.
13
+ *
14
+ * @param a The first iterable to zip.
15
+ * @param b The second iterable to zip.
16
+ *
17
+ * @yields Pairs of elements from the two iterables.
18
+ * @see {@linkcode zipAsync} for the asynchronous version.
19
+ */
20
+ export function* zipSync(a, b) {
21
+ const aIterator = a[Symbol.iterator]();
22
+ const bIterator = b[Symbol.iterator]();
23
+ let index = 0;
24
+ while (true) {
25
+ const { done: aDone, value: aValue } = aIterator.next();
26
+ const { done: bDone, value: bValue } = bIterator.next();
27
+ if (aDone && bDone) {
28
+ break;
29
+ }
30
+ yield [aValue, bValue, index];
31
+ index++;
32
+ }
33
+ }
34
+ /**
35
+ * Given two iterables, zip them together into a single iterable which yields pairs of elements.
36
+ *
37
+ * If one iterable is longer than the other, the shorter iterable will be padded with `undefined`.
38
+ *
39
+ * @param a The first iterable to zip.
40
+ * @param b The second iterable to zip.
41
+ *
42
+ * @yields Pairs of elements from the two iterables.
43
+ * @see {@linkcode zipSync} for the synchronous version.
44
+ */
45
+ export async function* zipAsync(a, b) {
46
+ const aIterator = Symbol.asyncIterator in a ? a[Symbol.asyncIterator]() : a[Symbol.iterator]();
47
+ const bIterator = Symbol.asyncIterator in b ? b[Symbol.asyncIterator]() : b[Symbol.iterator]();
48
+ let index = 0;
49
+ while (true) {
50
+ const { done: aDone, value: aValue } = await aIterator.next();
51
+ const { done: bDone, value: bValue } = await bIterator.next();
52
+ if (aDone && bDone) {
53
+ break;
54
+ }
55
+ yield [aValue, bValue, index];
56
+ index++;
57
+ }
58
+ }
59
+ //# sourceMappingURL=zip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zip.js","sourceRoot":"","sources":["../../lib/zip.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,MAAM,UAAU,aAAa,CAAO,MAAoB;IACvD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAgC,CAAA;AACzD,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,SAAS,CA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MAAM,SAAS,CAAC,IAAI,EAAE,CAAA;QAC7D,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,SAAS,CAAC,IAAI,EAAE,CAAA;QAE7D,IAAI,KAAK,IAAI,KAAK,EAAE,CAAC;YACpB,MAAK;QACN,CAAC;QAED,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,CAAA;QAE7B,KAAK,EAAE,CAAA;IACR,CAAC;AACF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spliterator",
3
- "version": "5.0.0",
3
+ "version": "6.0.1",
4
4
  "description": "Line-delimited iterator library for CSV, NDJSON, and other delimited formats.",
5
5
  "keywords": [
6
6
  "csv",
@@ -65,15 +65,15 @@
65
65
  "test": "yarn compile && vitest"
66
66
  },
67
67
  "devDependencies": {
68
- "@sister.software/oxfmt-config": "^11.0.0",
69
- "@sister.software/oxlint-config": "^11.0.0",
70
- "@sister.software/tsconfig": "^11.0.0",
68
+ "@sister.software/oxfmt-config": "^12.1.3",
69
+ "@sister.software/oxlint-config": "^12.1.3",
70
+ "@sister.software/tsconfig": "^12.1.3",
71
71
  "@types/node": "^26.1.2",
72
72
  "change-case": "^5.4.4",
73
73
  "colorette": "^2.0.20",
74
74
  "npm-run-all": "^4.1.5",
75
- "oxfmt": "0.61.0",
76
- "oxlint": "1.76.0",
75
+ "oxfmt": "0.62.0",
76
+ "oxlint": "1.77.0",
77
77
  "path-ts": "^2.1.0",
78
78
  "release-it": "^21.0.1",
79
79
  "type-fest": "^5.8.0",