spliterator 5.0.0 → 6.0.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 (58) 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/CSVSpliterator.d.ts +6 -5
  11. package/out/lib/CSVSpliterator.d.ts.map +1 -1
  12. package/out/lib/CSVSpliterator.js +46 -37
  13. package/out/lib/CSVSpliterator.js.map +1 -1
  14. package/out/lib/JSONSpliterator.d.ts +20 -9
  15. package/out/lib/JSONSpliterator.d.ts.map +1 -1
  16. package/out/lib/JSONSpliterator.js +25 -17
  17. package/out/lib/JSONSpliterator.js.map +1 -1
  18. package/out/lib/TextSpliterator.d.ts +4 -2
  19. package/out/lib/TextSpliterator.d.ts.map +1 -1
  20. package/out/lib/TextSpliterator.js +8 -9
  21. package/out/lib/TextSpliterator.js.map +1 -1
  22. package/out/lib/adaptive-source.d.ts +39 -0
  23. package/out/lib/adaptive-source.d.ts.map +1 -0
  24. package/out/lib/adaptive-source.js +95 -0
  25. package/out/lib/adaptive-source.js.map +1 -0
  26. package/out/lib/chunks.d.ts +20 -0
  27. package/out/lib/chunks.d.ts.map +1 -0
  28. package/out/lib/chunks.js +36 -0
  29. package/out/lib/chunks.js.map +1 -0
  30. package/out/lib/parallel-map-workers.d.ts +57 -0
  31. package/out/lib/parallel-map-workers.d.ts.map +1 -0
  32. package/out/lib/parallel-map-workers.js +82 -0
  33. package/out/lib/parallel-map-workers.js.map +1 -0
  34. package/out/lib/parallel-map.d.ts +17 -42
  35. package/out/lib/parallel-map.d.ts.map +1 -1
  36. package/out/lib/parallel-map.js +18 -66
  37. package/out/lib/parallel-map.js.map +1 -1
  38. package/out/lib/pivot.d.ts +30 -0
  39. package/out/lib/pivot.d.ts.map +1 -0
  40. package/out/lib/pivot.js +47 -0
  41. package/out/lib/pivot.js.map +1 -0
  42. package/out/lib/shared.d.ts +0 -27
  43. package/out/lib/shared.d.ts.map +1 -1
  44. package/out/lib/shared.js +0 -53
  45. package/out/lib/shared.js.map +1 -1
  46. package/out/lib/take.d.ts +16 -0
  47. package/out/lib/take.d.ts.map +1 -1
  48. package/out/lib/take.js +28 -0
  49. package/out/lib/take.js.map +1 -1
  50. package/out/lib/utils.d.ts +37 -0
  51. package/out/lib/utils.d.ts.map +1 -0
  52. package/out/lib/utils.js +39 -0
  53. package/out/lib/utils.js.map +1 -0
  54. package/out/lib/zip.d.ts +33 -0
  55. package/out/lib/zip.d.ts.map +1 -0
  56. package/out/lib/zip.js +59 -0
  57. package/out/lib/zip.js.map +1 -0
  58. package/package.json +6 -6
package/README.md CHANGED
@@ -153,6 +153,62 @@ for (const row of CSVSpliterator.from(largeCsvString)) {
153
153
 
154
154
  Correctness is identical either way; `whenReady()` only affects which scanner runs.
155
155
 
156
+ ## Choosing a primitive
157
+
158
+ The question that predicts the answer is not "how big is my file?" — it's **how much work happens per row.**
159
+
160
+ | Per-row work | What dominates | Reach for |
161
+ | ------------------------------------------------------------ | -------------- | --------------------------------------------------------------------------------------------------- |
162
+ | None — counting, segmenting, pulling a couple of fields | The scan | `Spliterator` raw byte ranges. The SIMD scanner earns its keep here (~5–6 GB/s vs ~600 MB/s for JS) |
163
+ | ~1–3 µs — `JSON.parse`, CSV → object, string normalize | The parse | Plain sequential `fromAsync`. Threads **lose** here (0.3–0.9×); JSONL runs ~0.5× of `readline` |
164
+ | Milliseconds — model inference, geocoding, crypto, image ops | Your handler | `parallelMapWorkers`, or `AsyncSpliterator.asManyWorkers` for one large file |
165
+ | I/O-bound — file fan-out, network | Latency | `parallelMap` (caller's thread). Concurrency peaks around 2–3, then **degrades** |
166
+
167
+ The line worth internalizing: **the scan is almost never your bottleneck unless you aren't parsing.** Measure before adopting a parallel primitive.
168
+
169
+ The naming encodes one rule:
170
+
171
+ > **If you can pass a closure, it runs on your thread. If you must pass a module path, it runs on another one.**
172
+
173
+ Closures can't cross a `postMessage` boundary, so `parallelMap` takes a function and `parallelMapWorkers` takes a path — and `asMany`/`asManyWorkers` divide the same way.
174
+
175
+ | | Caller's thread | Worker threads |
176
+ | --------------------- | --------------------------- | -------------------------------- |
177
+ | A collection of items | `parallelMap` | `parallelMapWorkers` |
178
+ | One large file | `AsyncSpliterator.asMany` | `AsyncSpliterator.asManyWorkers` |
179
+ | Just the boundaries | `AsyncSpliterator.segments` | (feeds either) |
180
+
181
+ ### Chaining
182
+
183
+ `fromAsync` returns an `AsyncSequence` — a lazy, chainable async iterator whose core methods (`map`, `filter`, `take`, `drop`, `flatMap`, `reduce`, `toArray`, `forEach`, `some`, `every`, `find`) match the [async iterator helpers proposal][helpers] in name and semantics. No polyfill required.
184
+
185
+ [helpers]: https://github.com/tc39/proposal-async-iterator-helpers
186
+
187
+ ```ts
188
+ const cakes = await JSONSpliterator.fromAsync<Row>("menu.jsonl", { delimiter: "\n" })
189
+ .filter((row) => row.category === "Ice Cream Cake")
190
+ .map((row) => row.item_name)
191
+ .take(10)
192
+ .toArray()
193
+ ```
194
+
195
+ Filtering happens while streaming, and `take(10)` closes the file handle instead of reading the rest. The operators fuse into a single pass rather than nesting one async generator per step, so chain depth is nearly free — doubling the operator count costs about 10%, where nesting would roughly double it. `flatMap`, `chunks`, and `parallelMap` are the exceptions, since they need inner-iterator state.
196
+
197
+ The synchronous `from` returns a plain generator, which already has the same helpers natively on Node 24+.
198
+
199
+ ### Small sources are read whole
200
+
201
+ Opening a file handle and standing up a read stream costs about 100µs, which is most of the work for a small file. So `fromAsync` reads sources of 128 KiB or less into memory and parses them synchronously — measured ~1.85× faster at 635 B and ~1.4× at 125 KiB. Output is identical either way.
202
+
203
+ The threshold is deliberately small. Above ~256 KiB the advantage stops being measurable, while the memory cost keeps growing — a 1 GiB file costs ~105 MB resident streamed against ~1.1 GB read whole. Raising it buys nothing and spends memory linearly.
204
+
205
+ ```ts
206
+ // Force streaming, whatever the size — when a bounded footprint is the point.
207
+ JSONSpliterator.fromAsync("data.jsonl", { delimiter: "\n", bulkThreshold: 0 })
208
+ ```
209
+
210
+ Sources with no knowable length (a pipe, a `ReadableStream`) get an end-of-input test instead: if the first chunk read is also the last, the whole input is already in memory and is parsed directly. Otherwise it streams as normal.
211
+
156
212
  ### Parallel parsing across threads
157
213
 
158
214
  For one large file with a CPU-bound per-row transform, `AsyncSpliterator.asManyWorkers` splits the file into delimiter-aligned segments and runs a handler module across worker threads — each worker owns its own handle and reads only its segment. Results stream back to the main thread as a single async iterator, for a single-thread writer (a database, a JSONL file).
package/out/index.d.ts CHANGED
@@ -3,21 +3,27 @@
3
3
  * @license MIT
4
4
  * @author Teffen Ellis, et al.
5
5
  */
6
+ export * from "./lib/adaptive-source.js";
7
+ export * from "./lib/AsyncSequence.js";
6
8
  export * from "./lib/BufferController.js";
7
9
  export * from "./lib/casing.js";
8
10
  export * from "./lib/CharacterSequence.js";
11
+ export * from "./lib/chunks.js";
9
12
  export * from "./lib/CompositeDataView.js";
10
13
  export * from "./lib/CSVSpliterator.js";
11
14
  export * from "./lib/IndexQueue.js";
12
15
  export * from "./lib/JSONSpliterator.js";
13
16
  export * from "./lib/parallel-map.js";
17
+ export * from "./lib/parallel-map-workers.js";
18
+ export * from "./lib/pivot.js";
14
19
  export * from "./lib/PSVSpliterator.js";
15
20
  export * from "./lib/segments.js";
16
21
  export * from "./lib/shared.js";
17
22
  export * from "./lib/SlidingWindow.js";
18
23
  export * from "./lib/Spliterator.js";
19
- export * from "./lib/take.js";
20
24
  export * from "./lib/TextSpliterator.js";
21
25
  export * from "./lib/TSVSpliterator.js";
26
+ export * from "./lib/utils.js";
22
27
  export * from "./lib/writer.js";
28
+ export * from "./lib/zip.js";
23
29
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,2BAA2B,CAAA;AACzC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,4BAA4B,CAAA;AAC1C,cAAc,4BAA4B,CAAA;AAC1C,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA;AACnC,cAAc,0BAA0B,CAAA;AACxC,cAAc,uBAAuB,CAAA;AACrC,cAAc,yBAAyB,CAAA;AACvC,cAAc,mBAAmB,CAAA;AACjC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,wBAAwB,CAAA;AACtC,cAAc,sBAAsB,CAAA;AACpC,cAAc,eAAe,CAAA;AAC7B,cAAc,0BAA0B,CAAA;AACxC,cAAc,yBAAyB,CAAA;AACvC,cAAc,iBAAiB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,0BAA0B,CAAA;AACxC,cAAc,wBAAwB,CAAA;AACtC,cAAc,2BAA2B,CAAA;AACzC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,4BAA4B,CAAA;AAC1C,cAAc,iBAAiB,CAAA;AAC/B,cAAc,4BAA4B,CAAA;AAC1C,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA;AACnC,cAAc,0BAA0B,CAAA;AACxC,cAAc,uBAAuB,CAAA;AACrC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,gBAAgB,CAAA;AAC9B,cAAc,yBAAyB,CAAA;AACvC,cAAc,mBAAmB,CAAA;AACjC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,wBAAwB,CAAA;AACtC,cAAc,sBAAsB,CAAA;AACpC,cAAc,0BAA0B,CAAA;AACxC,cAAc,yBAAyB,CAAA;AACvC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,cAAc,CAAA"}
package/out/index.js CHANGED
@@ -3,21 +3,27 @@
3
3
  * @license MIT
4
4
  * @author Teffen Ellis, et al.
5
5
  */
6
+ export * from "./lib/adaptive-source.js";
7
+ export * from "./lib/AsyncSequence.js";
6
8
  export * from "./lib/BufferController.js";
7
9
  export * from "./lib/casing.js";
8
10
  export * from "./lib/CharacterSequence.js";
11
+ export * from "./lib/chunks.js";
9
12
  export * from "./lib/CompositeDataView.js";
10
13
  export * from "./lib/CSVSpliterator.js";
11
14
  export * from "./lib/IndexQueue.js";
12
15
  export * from "./lib/JSONSpliterator.js";
13
16
  export * from "./lib/parallel-map.js";
17
+ export * from "./lib/parallel-map-workers.js";
18
+ export * from "./lib/pivot.js";
14
19
  export * from "./lib/PSVSpliterator.js";
15
20
  export * from "./lib/segments.js";
16
21
  export * from "./lib/shared.js";
17
22
  export * from "./lib/SlidingWindow.js";
18
23
  export * from "./lib/Spliterator.js";
19
- export * from "./lib/take.js";
20
24
  export * from "./lib/TextSpliterator.js";
21
25
  export * from "./lib/TSVSpliterator.js";
26
+ export * from "./lib/utils.js";
22
27
  export * from "./lib/writer.js";
28
+ export * from "./lib/zip.js";
23
29
  //# sourceMappingURL=index.js.map
package/out/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,2BAA2B,CAAA;AACzC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,4BAA4B,CAAA;AAC1C,cAAc,4BAA4B,CAAA;AAC1C,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA;AACnC,cAAc,0BAA0B,CAAA;AACxC,cAAc,uBAAuB,CAAA;AACrC,cAAc,yBAAyB,CAAA;AACvC,cAAc,mBAAmB,CAAA;AACjC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,wBAAwB,CAAA;AACtC,cAAc,sBAAsB,CAAA;AACpC,cAAc,eAAe,CAAA;AAC7B,cAAc,0BAA0B,CAAA;AACxC,cAAc,yBAAyB,CAAA;AACvC,cAAc,iBAAiB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,0BAA0B,CAAA;AACxC,cAAc,wBAAwB,CAAA;AACtC,cAAc,2BAA2B,CAAA;AACzC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,4BAA4B,CAAA;AAC1C,cAAc,iBAAiB,CAAA;AAC/B,cAAc,4BAA4B,CAAA;AAC1C,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA;AACnC,cAAc,0BAA0B,CAAA;AACxC,cAAc,uBAAuB,CAAA;AACrC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,gBAAgB,CAAA;AAC9B,cAAc,yBAAyB,CAAA;AACvC,cAAc,mBAAmB,CAAA;AACjC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,wBAAwB,CAAA;AACtC,cAAc,sBAAsB,CAAA;AACpC,cAAc,0BAA0B,CAAA;AACxC,cAAc,yBAAyB,CAAA;AACvC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,cAAc,CAAA"}
@@ -0,0 +1,180 @@
1
+ /**
2
+ * @copyright Sister Software
3
+ * @license MIT
4
+ * @author Teffen Ellis, et al.
5
+ */
6
+ import { ReadableStream, type ReadableWritablePair, type StreamPipeOptions } from "stream/web";
7
+ /**
8
+ * A chainable operation in a fused pipeline.
9
+ *
10
+ * Ops are **descriptors**, not closures over iteration state — `take`/`drop` counters live in the iterator, not here,
11
+ * so a sequence can describe its chain before anyone pulls from it.
12
+ */
13
+ type Op = {
14
+ kind: typeof OP_MAP;
15
+ fn: (value: any, counter: number) => unknown;
16
+ } | {
17
+ kind: typeof OP_FILTER;
18
+ fn: (value: any, counter: number) => unknown;
19
+ } | {
20
+ kind: typeof OP_TAKE;
21
+ limit: number;
22
+ } | {
23
+ kind: typeof OP_DROP;
24
+ limit: number;
25
+ };
26
+ declare const OP_MAP = 0;
27
+ declare const OP_FILTER = 1;
28
+ declare const OP_TAKE = 2;
29
+ declare const OP_DROP = 3;
30
+ /**
31
+ * What a sequence can be built over.
32
+ *
33
+ * The thunk form defers construction until the first pull, which is what lets a `fromAsync` whose underlying open is
34
+ * asynchronous still return a sequence synchronously — the caller chains immediately and no file is opened until
35
+ * something iterates.
36
+ */
37
+ export type SequenceSource<T> = AsyncIterable<T> | Iterable<T> | (() => AsyncIterable<T> | Iterable<T> | PromiseLike<AsyncIterable<T> | Iterable<T>>);
38
+ /**
39
+ * Options for {@linkcode AsyncSequence.parallelMap}.
40
+ */
41
+ export interface ParallelMapSequenceOptions {
42
+ /**
43
+ * Maximum callbacks in flight at once.
44
+ *
45
+ * For I/O-bound work this peaks **low** — often ~2–3 — and then _degrades_ as callers contend for the same disk or
46
+ * socket. Sweep it rather than reaching for `availableParallelism()`.
47
+ */
48
+ concurrency: number;
49
+ /**
50
+ * Abort signal. When aborted, iteration stops after the currently-yielded value; in-flight callbacks are allowed to
51
+ * settle so none reject unobserved.
52
+ */
53
+ signal?: AbortSignal;
54
+ }
55
+ /**
56
+ * A lazy, chainable async iterator.
57
+ *
58
+ * The core methods (`map`, `filter`, `take`, `drop`, `flatMap`, `reduce`, `toArray`, `forEach`, `some`, `every`,
59
+ * `find`) match the [async iterator helpers proposal][proposal] in name, arity, and semantics — including the `counter`
60
+ * second argument handed to every callback. Callbacks may return promises. Code written against this keeps working
61
+ * verbatim if the proposal ever ships natively.
62
+ *
63
+ * [proposal]: https://github.com/tc39/proposal-async-iterator-helpers
64
+ *
65
+ * **Chain depth is nearly free.** A chain is an op list plus a source, not nested generators, so one async boundary is
66
+ * paid per item no matter how many operators you stack; only the op loop grows. Measured on Node 26 over 2M items:
67
+ * ~5.4M items/s at three operators and ~4.9M/s at six, against ~2.3M/s for the equivalent nested-generator
68
+ * implementation, where each operator adds a microtask hop. Doubling the operator count costs ~10% here and would cost
69
+ * ~2× there. Only {@linkcode flatMap}, {@linkcode chunks}, and {@linkcode parallelMap} break fusion, because they need
70
+ * inner-iterator state.
71
+ *
72
+ * Callback results are awaited **only when thenable**, so synchronous callbacks — the common case — cost no microtask
73
+ * hop at all.
74
+ *
75
+ * **When not to reach for this.** Wrapping costs ~1.9× a bare async generator (~10.3M/s), one extra async frame per
76
+ * item. On parsed rows (`JSON.parse` at ~1–3µs) that is 3–8%, invisible. On raw {@linkcode Uint8Array} ranges with no
77
+ * per-row parse it is most of the cost — iterate the {@linkcode AsyncSpliterator} directly there.
78
+ *
79
+ * Single-shot, like the iterators the proposal specifies: iterating consumes the source.
80
+ */
81
+ export declare class AsyncSequence<T> implements AsyncIterableIterator<T> {
82
+ #private;
83
+ constructor(source: SequenceSource<unknown>, ops?: readonly Op[]);
84
+ /**
85
+ * Wrap any iterable or async iterable as a chainable sequence.
86
+ */
87
+ static from<T>(source: SequenceSource<T>): AsyncSequence<T>;
88
+ /**
89
+ * Transform each value. The callback receives `(value, counter)` and may return a promise.
90
+ */
91
+ map<U>(fn: (value: T, counter: number) => U | PromiseLike<U>): AsyncSequence<U>;
92
+ /**
93
+ * Keep values for which the callback is truthy. The callback receives `(value, counter)` and may return a promise.
94
+ */
95
+ filter(fn: (value: T, counter: number) => unknown): AsyncSequence<T>;
96
+ /**
97
+ * Yield at most `limit` values, then close the underlying iterator.
98
+ *
99
+ * The close is what makes this safe on a file-backed source — `take(5)` over a 40GB file releases the handle rather
100
+ * than leaving it open until GC.
101
+ */
102
+ take(limit: number): AsyncSequence<T>;
103
+ /**
104
+ * Skip the first `limit` values.
105
+ */
106
+ drop(limit: number): AsyncSequence<T>;
107
+ /**
108
+ * Map each value to an iterable and flatten one level.
109
+ *
110
+ * **Fusion barrier.** Unlike the other operators this needs inner-iterator state, so it starts a fresh fused segment
111
+ * rather than joining the current op list. Stacking `flatMap` costs one async boundary each; stacking
112
+ * `map`/`filter`/`take`/`drop` costs nothing.
113
+ */
114
+ flatMap<U>(fn: (value: T, counter: number) => AsyncIterable<U> | Iterable<U> | PromiseLike<AsyncIterable<U> | Iterable<U>>): AsyncSequence<U>;
115
+ /**
116
+ * Collect every remaining value into an array.
117
+ *
118
+ * **Reads the whole source into memory.** On a sequence backed by a file this defeats the point of streaming — filter
119
+ * and map first so only what you keep is materialized.
120
+ */
121
+ toArray(): Promise<T[]>;
122
+ /**
123
+ * Invoke the callback for each value, for side effects.
124
+ */
125
+ forEach(fn: (value: T, counter: number) => unknown): Promise<void>;
126
+ /**
127
+ * Fold the sequence to a single value. Without `initialValue` the first value seeds the accumulator, and an empty
128
+ * sequence is a `TypeError` — matching `Array.prototype.reduce`.
129
+ */
130
+ reduce(fn: (accumulator: T, value: T, counter: number) => T | PromiseLike<T>): Promise<T>;
131
+ reduce<U>(fn: (accumulator: U, value: T, counter: number) => U | PromiseLike<U>, initialValue: U): Promise<U>;
132
+ /**
133
+ * Whether any value satisfies the callback. Short-circuits and closes the underlying iterator.
134
+ */
135
+ some(fn: (value: T, counter: number) => unknown): Promise<boolean>;
136
+ /**
137
+ * Whether every value satisfies the callback. Short-circuits and closes the underlying iterator.
138
+ */
139
+ every(fn: (value: T, counter: number) => unknown): Promise<boolean>;
140
+ /**
141
+ * The first value satisfying the callback, or `undefined`. Short-circuits and closes the underlying iterator.
142
+ */
143
+ find(fn: (value: T, counter: number) => unknown): Promise<T | undefined>;
144
+ /**
145
+ * Group values into arrays of `size`, with a shorter final batch if the sequence does not divide evenly.
146
+ *
147
+ * Distinct from {@linkcode take}, which yields the first `size` _values_. Named for the [iterator chunking
148
+ * proposal](https://github.com/tc39/proposal-iterator-chunking).
149
+ *
150
+ * **Fusion barrier**, like {@linkcode flatMap}.
151
+ */
152
+ chunks(size: number): AsyncSequence<T[]>;
153
+ /**
154
+ * Map values through a callback with up to `concurrency` calls in flight, yielding in **completion order** — not
155
+ * input order.
156
+ *
157
+ * The callback is a closure, so it runs on the caller's thread. This overlaps _latency_ (file reads, network) and
158
+ * does nothing for CPU-bound work; for that, cross a thread boundary with `parallelMapWorkers` or
159
+ * `AsyncSpliterator.asManyWorkers`, which take a module path precisely because a closure cannot.
160
+ *
161
+ * **Fusion barrier**, like {@linkcode flatMap}.
162
+ */
163
+ parallelMap<U>(fn: (value: T, counter: number) => U | PromiseLike<U>, { concurrency, signal }: ParallelMapSequenceOptions): AsyncSequence<U>;
164
+ /**
165
+ * Expose the sequence as a web stream, for interop with `pipeThrough`/`pipeTo` consumers.
166
+ */
167
+ toReadableStream(): ReadableStream<T>;
168
+ /**
169
+ * Pipe the sequence through a transform stream.
170
+ */
171
+ pipeThrough<U>(transform: ReadableWritablePair<U, T>, options?: StreamPipeOptions): ReadableStream<U>;
172
+ next(): Promise<IteratorResult<T>>;
173
+ /**
174
+ * Close the sequence and release the underlying source.
175
+ */
176
+ return(): Promise<IteratorResult<T>>;
177
+ [Symbol.asyncIterator](): AsyncIterableIterator<T>;
178
+ }
179
+ export {};
180
+ //# sourceMappingURL=AsyncSequence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AsyncSequence.d.ts","sourceRoot":"","sources":["../../lib/AsyncSequence.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAAE,KAAK,oBAAoB,EAAE,KAAK,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAE9F;;;;;GAKG;AACH,KAAK,EAAE,GACJ;IAAE,IAAI,EAAE,OAAO,MAAM,CAAC;IAAC,EAAE,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAA;CAAE,GACrE;IAAE,IAAI,EAAE,OAAO,SAAS,CAAC;IAAC,EAAE,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAA;CAAE,GACxE;IAAE,IAAI,EAAE,OAAO,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACvC;IAAE,IAAI,EA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