@shutterstock/p-map-iterable 1.1.2 → 1.2.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/README.md CHANGED
@@ -4,9 +4,11 @@
4
4
 
5
5
  `@shutterstock/p-map-iterable` provides several classes that allow processing results of `p-map`-style mapper functions by iterating the results as they are completed, with backpressure to limit the number of items that are processed ahead of the consumer.
6
6
 
7
+ Use these classes for concurrent metadata lookups, capability probes, background status checks, or read/write pipelines. The [optional aliases](#optional-names-for-concurrent-work) `ConcurrentMapper`, `MappingQueue`, and `WorkerQueue` describe the input and result contracts without tying the work to a particular I/O operation.
8
+
7
9
  A common use case for `@shutterstock/p-map-iterable` is as a "prefetcher" that will fetch, for example, AWS S3 files in an AWS Lambda function. By prefetching large files the consumer is able to use 100% of the paid-for Lambda CPU time for the JS thread, rather than waiting idle while the next file is fetched. The backpressure (set by `maxUnread`) prevents the prefetcher from consuming unlimited memory or disk space by racing ahead of the consumer.
8
10
 
9
- These classes will typically be helpful in batch or queue consumers, not as much in request/response services.
11
+ The caller supplies the operation to run for each input. Concurrency overlaps asynchronous work in the current JavaScript process; synchronous CPU work still uses the JavaScript event loop.
10
12
 
11
13
  # Example Usage Scenarios
12
14
 
@@ -25,14 +27,14 @@ for (const sourceId of sourceIds) {
25
27
 
26
28
  Each iteration takes 820ms total, but we waste time waiting for I/O. We could prefetch the next read (300ms) while processing (20ms) and writing (500ms), without changing the order of reads or writes.
27
29
 
28
- ## Using `IterableMapper` as Prefetcher with Blocking Sequential Writes
30
+ ## Prefetching with `IterableMapper` and Blocking Sequential Writes
29
31
 
30
- `concurrency: 1` on the prefetcher preserves the order of the reads and and writes are sequential and blocking (unchanged).
32
+ `concurrency: 1` on the prefetcher preserves the order of the reads, and writes remain sequential and blocking.
31
33
 
32
34
  ```typescript
33
35
  const source = new SomeSource();
34
36
  const sourceIds = [1, 2,... 1000];
35
- // Pre-reads up to 8 items serially and releases in sequential order
37
+ // Prefetches serially within maxUnread and releases results in sequential order
36
38
  const sourcePrefetcher = new IterableMapper(sourceIds,
37
39
  async (sourceId) => source.read(sourceId),
38
40
  { concurrency: 1, maxUnread: 10 }
@@ -46,7 +48,7 @@ for await (const item of sourcePrefetcher) { // may not block for fast source
46
48
 
47
49
  This reduces iteration time to 520ms by overlapping reads with processing/writing.
48
50
 
49
- ## Using `IterableMapper` as Prefetcher with Background Sequential Writes with `IterableQueueMapperSimple`
51
+ ## Prefetching with `IterableMapper` and Background Sequential Writes with `IterableQueueMapperSimple`
50
52
 
51
53
  `concurrency: 1` on the prefetcher preserves the order of the reads.
52
54
  `concurrency: 1` on the flusher preserves the order of the writes, but allows the loop to iterate while last write is completing.
@@ -67,7 +69,7 @@ for await (const item of sourcePrefetcher) { // may not block for fast source
67
69
  const outputItem = doSomeOperation(item); // takes 20 ms of CPU
68
70
  await flusher.enqueue(outputItem); // will periodically block for portion of write time
69
71
  }
70
- // Wait for all writes to complete
72
+ // Close input permanently after the last enqueue and wait for all writes
71
73
  await flusher.onIdle();
72
74
  // Check for errors
73
75
  if (flusher.errors.length > 0) {
@@ -80,7 +82,7 @@ by overlapping reads and writes with the CPU processing step.
80
82
  In this contrived example, the loop time is reduced to 500ms - 20ms = 480ms.
81
83
  In cases where the CPU usage time is higher, the impact can be greater.
82
84
 
83
- ## Using `IterableMapper` as Prefetcher with Out of Order Reads and Background Out of Order Writes with `IterableQueueMapperSimple`
85
+ ## Prefetching with `IterableMapper` and Out of Order Background Writes with `IterableQueueMapperSimple`
84
86
 
85
87
  For maximum throughput, allow out of order reads and writes with
86
88
  `IterableQueueMapper` (to iterate results with backpressure when too many unread items) or
@@ -102,7 +104,7 @@ for await (const item of sourcePrefetcher) { // typically will not block
102
104
  const outputItem = doSomeOperation(item); // takes 20 ms of CPU
103
105
  await flusher.enqueue(outputItem); // typically will not block
104
106
  }
105
- // Wait for all writes to complete
107
+ // Close input permanently after the last enqueue and wait for all writes
106
108
  await flusher.onIdle();
107
109
  // Check for errors
108
110
  if (flusher.errors.length > 0) {
@@ -152,6 +154,7 @@ These diagrams illustrate the differences in operation betweeen `p-map`, `p-queu
152
154
  # Features
153
155
 
154
156
  - [IterableMapper](https://tech.shutterstock.com/p-map-iterable/classes/IterableMapper.html)
157
+ - Also exported as `ConcurrentMapper`
155
158
  - Interface and concept based on: [p-map](https://github.com/sindresorhus/p-map)
156
159
  - Allows a sync or async iterable input
157
160
  - User supplied sync or async mapper function
@@ -159,13 +162,15 @@ These diagrams illustrate the differences in operation betweeen `p-map`, `p-queu
159
162
  - Allows a maximum queue depth of mapped items - if the consumer stops consuming, the queue will fill up, at which point the mapper will stop being invoked until an item is consumed from the queue
160
163
  - This allows mapping with backpressure so that the mapper does not consume unlimited resources (e.g. memory, disk, network, event loop time) by racing ahead of the consumer
161
164
  - [IterableQueueMapper](https://tech.shutterstock.com/p-map-iterable/classes/IterableQueueMapper.html)
165
+ - Also exported as `MappingQueue`
162
166
  - Wraps `IterableMapper`
163
167
  - Adds items to the queue via the `enqueue` method
164
168
  - [IterableQueueMapperSimple](https://tech.shutterstock.com/p-map-iterable/classes/IterableQueueMapperSimple.html)
169
+ - Also exported as `WorkerQueue`
165
170
  - Wraps `IterableQueueMapper`
166
171
  - Discards results as they become available
167
172
  - Exposes any accumulated errors through the `errors` property instead of throwing an `AggregateError`
168
- - Not actually `Iterable` - May rename this before 1.0.0
173
+ - Consumes results internally and exposes no result iterator
169
174
 
170
175
  ## Lower Level Utilities
171
176
  - [IterableQueue](https://tech.shutterstock.com/p-map-iterable/classes/IterableQueue.html)
@@ -184,30 +189,87 @@ See [p-map](https://github.com/sindresorhus/p-map) docs for a good start in unde
184
189
 
185
190
  The key difference between `IterableMapper` and `pMap` are that `IterableMapper` does not return when the entire mapping is done, rather it exposes an iterable that the caller loops through. This enables results to be processed while the mapping is still happening, while optionally allowing for backpressure to slow or stop the mapping if the caller is not consuming items fast enough. Common use cases include `prefetching` items from a remote service - the next set of requests are dispatched asyncronously while the current responses are processed and the prefetch requests will pause when the unread queue fills up.
186
191
 
192
+ `ConcurrentMapper` is an alias for this class. It also fits general mapping work such as enriching project metadata or probing a list of services. Consume results with `for await`; with `concurrency` greater than one, results can arrive out of input order.
193
+
187
194
  See [examples/iterable-mapper.ts](./examples/iterable-mapper.ts) for an example.
188
195
 
189
- Run the example with `npm run example:iterable-mapper`
196
+ Run the example with `pnpm run example:iterable-mapper`
190
197
 
191
198
  # `IterableQueueMapper`
192
199
 
193
200
  `IterableQueueMapper` is similar to `IterableMapper` but instead of taking an iterable input it instead adds data via the `enqueue` method which will block if `maxUnread` will be reached by the current number of `mapper`'s running in parallel.
194
201
 
202
+ `MappingQueue` is an alias for this class. Produce inputs and consume mapped results concurrently so the result buffer can drain. After the last awaited enqueue, call `done()` and finish consuming the iterator; `done()` closes input and does not wait for work to complete.
203
+
195
204
  See [examples/iterable-queue-mapper.ts](./examples/iterable-queue-mapper.ts) for an example.
196
205
 
197
- Run the example with `npm run example:iterable-queue-mapper`
206
+ Run the example with `pnpm run example:iterable-queue-mapper`
198
207
 
199
208
  # `IterableQueueMapperSimple`
200
209
 
201
210
  `IterableQueueMapperSimple` is similar to `IterableQueueMapper` but instead exposing the results as an iterable it discards the results as soon as they are ready and exposes any errors through the `errors` property.
202
211
 
212
+ `WorkerQueue` is an alias for this class. Supply one worker callback to process every enqueued input, such as a background Git status check. Await each enqueue for producer backpressure. After the last enqueue, await `onIdle()` to permanently close input and finish the accepted work, then inspect `errors`. An enqueue resolves when the input is accepted, rather than when its work completes.
213
+
203
214
  See [examples/iterable-queue-mapper-simple.ts](./examples/iterable-queue-mapper-simple.ts) for an example.
204
215
 
205
- Run the example with `npm run example:iterable-queue-mapper-simple`
216
+ Run the example with `pnpm run example:iterable-queue-mapper-simple`
217
+
218
+ ## Optional names for concurrent work
219
+
220
+ The package exports three optional class aliases. Choose the name that makes the input and result contracts clearest in your application:
221
+
222
+ | Alias | Original class | Input | Results and completion |
223
+ | --- | --- | --- | --- |
224
+ | `ConcurrentMapper` | `IterableMapper` | Sync or async iterable | Consume mapped results with `for await`. Mapping pauses when the unread result buffer fills. |
225
+ | `MappingQueue` | `IterableQueueMapper` | Awaited `enqueue(item)` calls | Consume results concurrently with production. Call `done()` after the last enqueue, then finish consuming the iterator. |
226
+ | `WorkerQueue` | `IterableQueueMapperSimple` | Awaited `enqueue(item)` calls | Results are consumed internally. After the last enqueue, await `onIdle()` and check `errors`. |
227
+
228
+ ```typescript
229
+ import {
230
+ ConcurrentMapper,
231
+ MappingQueue,
232
+ WorkerQueue,
233
+ } from '@shutterstock/p-map-iterable';
234
+ ```
235
+
236
+ The aliases are the original classes, with the same constructor identity, generic instance types, and subclassing behavior. Existing imports continue to work. Defaults, result ordering, backpressure, and error handling are identical through either name.
237
+
238
+ Matching option types are available from the package root using `import type`:
239
+
240
+ | Option alias | Original option type | Configuration |
241
+ | --- | --- | --- |
242
+ | `ConcurrentMapperOptions` | `IterableMapperOptions` | `concurrency`, `maxUnread`, `stopOnMapperError` |
243
+ | `MappingQueueOptions` | `IterableQueueMapperOptions` | `concurrency`, `maxUnread`, `stopOnMapperError` |
244
+ | `WorkerQueueOptions` | `IterableQueueMapperSimpleOptions` | `concurrency` |
245
+
246
+ `MappingQueue` must have a result consumer even when you do not need the results. Awaiting every enqueue before starting iteration can block once the result buffer fills. Use `WorkerQueue` when results can be discarded. Its `onIdle()` permanently ends input; subsequent enqueues reject. Worker failures are collected in `errors` while other inputs continue to run, so check that property after shutdown.
247
+
248
+ Each queue uses one fixed callback supplied at construction. Awaiting `enqueue()` provides producer backpressure and confirms acceptance of an input. Calling it without awaiting can accumulate pending inputs. For ongoing event-driven work, the application supplies any admission limits, cancellation, deduplication, or per-item completion handles. `WorkerQueue.onIdle()` is a final shutdown operation, so an application that needs reusable idle waits must manage that separately.
249
+
250
+ See [examples/semantic-aliases.ts](./examples/semantic-aliases.ts) for metadata enrichment, queued capability probes with a concurrent result consumer, and background status checks with collected errors. Run it with `pnpm run example:semantic-aliases`.
206
251
 
207
252
  # Contributing - Setting up Build Environment
208
253
 
209
- - `nvm use`
210
- - `npm i`
211
- - `npm run build`
212
- - `npm run lint`
213
- - `npm run test`
254
+ Use Node.js 24 and the pnpm version pinned in `package.json`:
255
+
256
+ ```sh
257
+ nvm use
258
+ corepack enable pnpm
259
+ corepack prepare pnpm@12.7.0 --activate
260
+ pnpm install --frozen-lockfile
261
+ pnpm run build
262
+ pnpm run build:docs
263
+ pnpm run lint
264
+ pnpm run test
265
+ pnpm run example:semantic-aliases
266
+ ```
267
+
268
+ Corepack enforces the pnpm version in `package.json`. pnpm's additional package
269
+ manager switching is disabled to keep the single-document lockfile readable by
270
+ GitHub's dependency graph and Dependabot. The pnpm configuration requires package
271
+ releases to be at least seven days old.
272
+ On macOS, `packageImportMethod: auto` prefers APFS copy-on-write clones from the
273
+ shared pnpm store, so worktrees share package data until a file changes. Keep the
274
+ store on the same APFS volume as the checkout. Other supported filesystems use
275
+ pnpm's available import method.
@@ -36,10 +36,6 @@ class BlockingQueue {
36
36
  this._doneAdding = false;
37
37
  const { maxUnread = 8 } = options;
38
38
  this._options = { maxUnread };
39
- // Avoid undefined errors on options
40
- if (this._options.maxUnread === undefined) {
41
- throw new TypeError('`maxUnread` must be set');
42
- }
43
39
  // Validate maxUnread option
44
40
  if (!((Number.isSafeInteger(this._options.maxUnread) ||
45
41
  this._options.maxUnread === Number.POSITIVE_INFINITY) &&
@@ -77,14 +73,9 @@ class BlockingQueue {
77
73
  }
78
74
  // We always add to the internal queue, we just wait to return if the queue is full
79
75
  this._unreadQueue.enqueue(item);
80
- if (this._readersWaiting.length > 0) {
81
- // Release a reader if one is waiting for an item
82
- // Remove the first waiting reader Promise from the queue
83
- const reader = this._readersWaiting.dequeue();
84
- if (reader === undefined) {
85
- throw new TypeError('reader queue returned undefined');
86
- }
87
- // Resolve the Promise for a waiting reader
76
+ // Take the oldest reader if one is waiting; an empty queue returns undefined.
77
+ const reader = this._readersWaiting.dequeue();
78
+ if (reader !== undefined) {
88
79
  reader(undefined);
89
80
  }
90
81
  if (this._unreadQueue.length > this._options.maxUnread) {
@@ -115,14 +106,9 @@ class BlockingQueue {
115
106
  await this.waitForWrite();
116
107
  item = this._unreadQueue.dequeue();
117
108
  }
118
- if (this._writersWaiting.length > 0) {
119
- // Release a writer if one is waiting
120
- // Remove the first waiting reader Promise from the queue
121
- const writer = this._writersWaiting.dequeue();
122
- if (writer === undefined) {
123
- throw new TypeError('writer queue returned undefined');
124
- }
125
- // Resolve the Promise for a waiting writer
109
+ // Take the oldest writer if one is waiting; an empty queue returns undefined.
110
+ const writer = this._writersWaiting.dequeue();
111
+ if (writer !== undefined) {
126
112
  writer(undefined);
127
113
  }
128
114
  return item;
@@ -1 +1 @@
1
- {"version":3,"file":"blocking-queue.js","sourceRoot":"","sources":["../../src/blocking-queue.ts"],"names":[],"mappings":";;;AAAA,mCAAgC;AAkBhC;;;;;;;GAOG;AACH,MAAa,aAAa;IAwBxB;;;;OAIG;IACH,YAAY,UAAgC,EAAE;QA1B9C,mFAAmF;QACnF,8EAA8E;QAC9E,yEAAyE;QACxD,iBAAY,GAAmB,IAAI,aAAK,EAAE,CAAC;QAE5D,8EAA8E;QAC9E,+EAA+E;QAC/E,gDAAgD;QAChD,2EAA2E;QAC3E,YAAY;QACK,oBAAe,GAA8B,IAAI,aAAK,EAAE,CAAC;QAE1E,6EAA6E;QAC7E,+EAA+E;QAC/E,gDAAgD;QAChD,2EAA2E;QAC3E,YAAY;QACK,oBAAe,GAA8B,IAAI,aAAK,EAAE,CAAC;QAElE,gBAAW,GAAG,KAAK,CAAC;QAQ1B,MAAM,EAAE,SAAS,GAAG,CAAC,EAAE,GAAG,OAAO,CAAC;QAClC,IAAI,CAAC,QAAQ,GAAG,EAAE,SAAS,EAAE,CAAC;QAE9B,oCAAoC;QACpC,IAAI,IAAI,CAAC,QAAQ,CAAC,SAAS,KAAK,SAAS,EAAE;YACzC,MAAM,IAAI,SAAS,CAAC,yBAAyB,CAAC,CAAC;SAChD;QAED,4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,0CAA0C;YAC1C,IAAI,IAAI,CAAC,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE;gBACrC,gDAAgD;gBAChD,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE;oBAClC,iCAAiC;oBACjC,IAAI,CAAC,iBAAiB,EAAE,CAAC;oBAEzB,OAAO,IAAI,CAAC;iBACb;aACF;SACF;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM;IACN,gDAAgD;IAChD,wCAAwC;IACxC,MAAM;IACN,gEAAgE;IAChE,4EAA4E;IAC5E,sFAAsF;IACtF,iDAAiD;IACjD,6CAA6C;IAC7C,QAAQ;IAER,qCAAqC;IACrC,qBAAqB;IAErB,8CAA8C;IAE9C,oCAAoC;IACpC,iBAAiB;IACjB,IAAI;IAEJ;;OAEG;IACK,KAAK,CAAC,YAAY;QACxB,uEAAuE;QACvE,iFAAiF;QACjF,MAAM,SAAS,GAAG,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YACxC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACxC,CAAC,CAAC,CAAC;QAEH,gCAAgC;QAChC,MAAM,SAAS,CAAC;IAClB,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,WAAW;QACvB,uEAAuE;QACvE,iFAAiF;QACjF,MAAM,UAAU,GAAG,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YACzC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACxC,CAAC,CAAC,CAAC;QAEH,wCAAwC;QACxC,MAAM,UAAU,CAAC;IACnB,CAAC;CACF;AA3ND,sCA2NC"}
1
+ {"version":3,"file":"blocking-queue.js","sourceRoot":"","sources":["../../src/blocking-queue.ts"],"names":[],"mappings":";;;AAAA,mCAAgC;AAkBhC;;;;;;;GAOG;AACH,MAAa,aAAa;IAwBxB;;;;OAIG;IACH,YAAY,UAAgC,EAAE;QA1B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AO,EAAE,EAAE;YACzC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACxC,CAAC,CAAC,CAAC;QAEH,wCAAwC;QACxC,MAAM,UAAU,CAAC;IACnB,CAAC;CACF;AAxMD,sCAwMC"}
@@ -2,7 +2,8 @@ import { Mapper, IterableMapper, IterableMapperOptions } from './iterable-mapper
2
2
  import { BlockingQueue, BlockingQueueOptions } from './blocking-queue';
3
3
  import { IterableQueue, IterableQueueOptions } from './iterable-queue';
4
4
  import { IterableQueueMapper, IterableQueueMapperOptions } from './iterable-queue-mapper';
5
- import { IterableQueueMapperSimple } from './iterable-queue-mapper-simple';
5
+ import { IterableQueueMapperSimple, IterableQueueMapperSimpleOptions } from './iterable-queue-mapper-simple';
6
6
  import { Queue } from './queue';
7
- export { Mapper, IterableMapper, IterableMapperOptions, IterableQueueMapper, IterableQueueMapperOptions, IterableQueueMapperSimple, BlockingQueue, BlockingQueueOptions, IterableQueue, IterableQueueOptions, Queue, };
7
+ export { IterableMapper, IterableMapper as ConcurrentMapper, IterableQueueMapper, IterableQueueMapper as MappingQueue, IterableQueueMapperSimple, IterableQueueMapperSimple as WorkerQueue, BlockingQueue, IterableQueue, Queue, };
8
+ export type { Mapper, IterableMapperOptions, IterableMapperOptions as ConcurrentMapperOptions, IterableQueueMapperOptions, IterableQueueMapperOptions as MappingQueueOptions, IterableQueueMapperSimpleOptions, IterableQueueMapperSimpleOptions as WorkerQueueOptions, BlockingQueueOptions, IterableQueueOptions, };
8
9
  //# sourceMappingURL=index.d.ts.map
package/dist/src/index.js CHANGED
@@ -1,16 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Queue = exports.IterableQueue = exports.BlockingQueue = exports.IterableQueueMapperSimple = exports.IterableQueueMapper = exports.IterableMapper = void 0;
3
+ exports.Queue = exports.IterableQueue = exports.BlockingQueue = exports.WorkerQueue = exports.IterableQueueMapperSimple = exports.MappingQueue = exports.IterableQueueMapper = exports.ConcurrentMapper = exports.IterableMapper = void 0;
4
4
  const iterable_mapper_1 = require("./iterable-mapper");
5
5
  Object.defineProperty(exports, "IterableMapper", { enumerable: true, get: function () { return iterable_mapper_1.IterableMapper; } });
6
+ Object.defineProperty(exports, "ConcurrentMapper", { enumerable: true, get: function () { return iterable_mapper_1.IterableMapper; } });
6
7
  const blocking_queue_1 = require("./blocking-queue");
7
8
  Object.defineProperty(exports, "BlockingQueue", { enumerable: true, get: function () { return blocking_queue_1.BlockingQueue; } });
8
9
  const iterable_queue_1 = require("./iterable-queue");
9
10
  Object.defineProperty(exports, "IterableQueue", { enumerable: true, get: function () { return iterable_queue_1.IterableQueue; } });
10
11
  const iterable_queue_mapper_1 = require("./iterable-queue-mapper");
11
12
  Object.defineProperty(exports, "IterableQueueMapper", { enumerable: true, get: function () { return iterable_queue_mapper_1.IterableQueueMapper; } });
13
+ Object.defineProperty(exports, "MappingQueue", { enumerable: true, get: function () { return iterable_queue_mapper_1.IterableQueueMapper; } });
12
14
  const iterable_queue_mapper_simple_1 = require("./iterable-queue-mapper-simple");
13
15
  Object.defineProperty(exports, "IterableQueueMapperSimple", { enumerable: true, get: function () { return iterable_queue_mapper_simple_1.IterableQueueMapperSimple; } });
16
+ Object.defineProperty(exports, "WorkerQueue", { enumerable: true, get: function () { return iterable_queue_mapper_simple_1.IterableQueueMapperSimple; } });
14
17
  const queue_1 = require("./queue");
15
18
  Object.defineProperty(exports, "Queue", { enumerable: true, get: function () { return queue_1.Queue; } });
16
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,uDAAkF;AAShF,+FATe,gCAAc,OASf;AARhB,qDAAuE;AAarE,8FAbO,8BAAa,OAaP;AAZf,qDAAuE;AAcrE,8FAdO,8BAAa,OAcP;AAbf,mEAA0F;AAQxF,oGARO,2CAAmB,OAQP;AAPrB,iFAA2E;AASzE,0GATO,wDAAyB,OASP;AAR3B,mCAAgC;AAa9B,sFAbO,aAAK,OAaP"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,uDAAkF;AAWhF,+FAXe,gCAAc,OAWf;AACI,iGAZH,gCAAc,OAYK;AAXpC,qDAAuE;AAgBrE,8FAhBO,8BAAa,OAgBP;AAff,qDAAuE;AAgBrE,8FAhBO,8BAAa,OAgBP;AAff,mEAA0F;AAUxF,oGAVO,2CAAmB,OAUP;AACI,6FAXhB,2CAAmB,OAWS;AAVrC,iFAGwC;AAQtC,0GAVA,wDAAyB,OAUA;AACI,4FAX7B,wDAAyB,OAWe;AAR1C,mCAAgC;AAW9B,sFAXO,aAAK,OAWP"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Options for IterableMapper
2
+ * Options for `IterableMapper`, also exported as `ConcurrentMapperOptions`.
3
3
  */
4
4
  export interface IterableMapperOptions {
5
5
  /**
@@ -56,7 +56,7 @@ export interface IterableMapperOptions {
56
56
  * @template Element - Source element type
57
57
  * @template NewElement - Element type returned by the mapper
58
58
  * @param element - Iterated element
59
- * @param index - Index of the element in the source array
59
+ * @param index - Zero-based index of the input element
60
60
  */
61
61
  export type Mapper<Element = unknown, NewElement = unknown> = (element: Element, index: number) => NewElement | Promise<NewElement>;
62
62
  /**
@@ -65,9 +65,14 @@ export type Mapper<Element = unknown, NewElement = unknown> = (element: Element,
65
65
  * `mapper` result in a queue of `maxUnread` size, before
66
66
  * being iterated / read by the caller.
67
67
  *
68
+ * Also exported as `ConcurrentMapper`, with the same constructor and instance types.
69
+ * Concurrency overlaps asynchronous callback work in the current JavaScript process.
70
+ * Results can arrive out of input order when `concurrency` is greater than one.
71
+ *
68
72
  * @remarks
69
73
  *
70
- * ### Typical Use Case
74
+ * ### Typical Use Cases
75
+ * - Enriching metadata or probing capabilities for a sync or async iterable of inputs
71
76
  * - Prefetching items from an async I/O source
72
77
  * - In the simple sequential (`concurrency: 1`) case, allows items to be prefetched async, preserving order, while caller processes an item
73
78
  * - Can allow parallel prefetches for sources that allow for out of order reads (`concurrency: 2+`)
@@ -88,7 +93,8 @@ export type Mapper<Element = unknown, NewElement = unknown> = (element: Element,
88
93
  *
89
94
  * ### Usage
90
95
  * - Items are exposed to the `mapper` via an iterator or async iterator (this includes generator and async generator functions)
91
- * - IMPORTANT: `mapper` method not be invoked when `maxUnread` is reached, until items are consumed
96
+ * - Consume results with `for await` while mapping proceeds
97
+ * - The `mapper` will not be invoked when `maxUnread` is reached, until items are consumed
92
98
  * - The iterable will set `done` when the `input` has indicated `done` and all `mapper` promises have resolved
93
99
  *
94
100
  * @example
@@ -112,14 +118,14 @@ export type Mapper<Element = unknown, NewElement = unknown> = (element: Element,
112
118
  *
113
119
  * @example
114
120
  *
115
- * ### Using `IterableMapper` as Prefetcher with Blocking Sequential Writes
121
+ * ### Prefetching with `IterableMapper` and Blocking Sequential Writes
116
122
  *
117
- * `concurrency: 1` on the prefetcher preserves the order of the reads and and writes are sequential and blocking (unchanged).
123
+ * `concurrency: 1` on the prefetcher preserves the order of the reads, and writes remain sequential and blocking.
118
124
  *
119
125
  * ```typescript
120
126
  * const source = new SomeSource();
121
127
  * const sourceIds = [1, 2,... 1000];
122
- * // Pre-reads up to 8 items serially and releases in sequential order
128
+ * // Prefetches serially within maxUnread and releases results in sequential order
123
129
  * const sourcePrefetcher = new IterableMapper(sourceIds,
124
130
  * async (sourceId) => source.read(sourceId),
125
131
  * { concurrency: 1, maxUnread: 10 }
@@ -135,7 +141,7 @@ export type Mapper<Element = unknown, NewElement = unknown> = (element: Element,
135
141
  *
136
142
  * @example
137
143
  *
138
- * ### Using `IterableMapper` as Prefetcher with Background Sequential Writes with `IterableQueueMapperSimple`
144
+ * ### Prefetching with `IterableMapper` and Background Sequential Writes with `IterableQueueMapperSimple`
139
145
  *
140
146
  * `concurrency: 1` on the prefetcher preserves the order of the reads.
141
147
  * `concurrency: 1` on the flusher preserves the order of the writes, but allows the loop to iterate while last write is completing.
@@ -156,7 +162,7 @@ export type Mapper<Element = unknown, NewElement = unknown> = (element: Element,
156
162
  * const outputItem = doSomeOperation(item); // takes 20 ms of CPU
157
163
  * await flusher.enqueue(outputItem); // will periodically block for portion of write time
158
164
  * }
159
- * // Wait for all writes to complete
165
+ * // Close input permanently after the last enqueue and wait for all writes
160
166
  * await flusher.onIdle();
161
167
  * // Check for errors
162
168
  * if (flusher.errors.length > 0) {
@@ -171,7 +177,7 @@ export type Mapper<Element = unknown, NewElement = unknown> = (element: Element,
171
177
  *
172
178
  * @example
173
179
  *
174
- * ### Using `IterableMapper` as Prefetcher with Out of Order Reads and Background Out of Order Writes with `IterableQueueMapperSimple`
180
+ * ### Prefetching with `IterableMapper` and Out of Order Background Writes with `IterableQueueMapperSimple`
175
181
  *
176
182
  * For maximum throughput, allow out of order reads and writes with
177
183
  * `IterableQueueMapper` (to iterate results with backpressure when too many unread items) or
@@ -193,7 +199,7 @@ export type Mapper<Element = unknown, NewElement = unknown> = (element: Element,
193
199
  * const outputItem = doSomeOperation(item); // takes 20 ms of CPU
194
200
  * await flusher.enqueue(outputItem); // typically will not block
195
201
  * }
196
- * // Wait for all writes to complete
202
+ * // Close input permanently after the last enqueue and wait for all writes
197
203
  * await flusher.onIdle();
198
204
  * // Check for errors
199
205
  * if (flusher.errors.length > 0) {
@@ -227,7 +233,7 @@ export declare class IterableMapper<Element, NewElement> implements AsyncIterabl
227
233
  * @param mapper Function called for every item in `input`. Returns a `Promise` or value.
228
234
  * @param options IterableMapper options
229
235
  *
230
- * @see {@link IterableQueueMapper} for full class documentation
236
+ * @see {@link IterableMapper} for full class documentation
231
237
  */
232
238
  constructor(input: AsyncIterable<Element> | Iterable<Element>, mapper: Mapper<Element, NewElement>, options?: IterableMapperOptions);
233
239
  [Symbol.asyncIterator](): AsyncIterator<NewElement>;
@@ -240,7 +246,6 @@ export declare class IterableMapper<Element, NewElement> implements AsyncIterabl
240
246
  next(): Promise<IteratorResult<NewElement>>;
241
247
  private bubbleUpErrors;
242
248
  private startARunnerIfNeeded;
243
- private startAnotherRunner;
244
249
  private areWeDone;
245
250
  /**
246
251
  * Throw an exception if the wrapped NewElement is an Error
@@ -1,11 +1,13 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.IterableMapper = void 0;
4
2
  //
5
3
  // 2021-08-25 - Initially based on: https://raw.githubusercontent.com/sindresorhus/p-map/main/index.js
6
4
  //
7
- // eslint-disable-next-line @typescript-eslint/no-var-requires
8
- const AggregateError = require('aggregate-error');
5
+ var __importDefault = (this && this.__importDefault) || function (mod) {
6
+ return (mod && mod.__esModule) ? mod : { "default": mod };
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.IterableMapper = void 0;
10
+ const aggregate_error_1 = __importDefault(require("aggregate-error"));
9
11
  const iterable_queue_1 = require("./iterable-queue");
10
12
  /**
11
13
  * Iterates over a source iterable / generator with specified `concurrency`,
@@ -13,9 +15,14 @@ const iterable_queue_1 = require("./iterable-queue");
13
15
  * `mapper` result in a queue of `maxUnread` size, before
14
16
  * being iterated / read by the caller.
15
17
  *
18
+ * Also exported as `ConcurrentMapper`, with the same constructor and instance types.
19
+ * Concurrency overlaps asynchronous callback work in the current JavaScript process.
20
+ * Results can arrive out of input order when `concurrency` is greater than one.
21
+ *
16
22
  * @remarks
17
23
  *
18
- * ### Typical Use Case
24
+ * ### Typical Use Cases
25
+ * - Enriching metadata or probing capabilities for a sync or async iterable of inputs
19
26
  * - Prefetching items from an async I/O source
20
27
  * - In the simple sequential (`concurrency: 1`) case, allows items to be prefetched async, preserving order, while caller processes an item
21
28
  * - Can allow parallel prefetches for sources that allow for out of order reads (`concurrency: 2+`)
@@ -36,7 +43,8 @@ const iterable_queue_1 = require("./iterable-queue");
36
43
  *
37
44
  * ### Usage
38
45
  * - Items are exposed to the `mapper` via an iterator or async iterator (this includes generator and async generator functions)
39
- * - IMPORTANT: `mapper` method not be invoked when `maxUnread` is reached, until items are consumed
46
+ * - Consume results with `for await` while mapping proceeds
47
+ * - The `mapper` will not be invoked when `maxUnread` is reached, until items are consumed
40
48
  * - The iterable will set `done` when the `input` has indicated `done` and all `mapper` promises have resolved
41
49
  *
42
50
  * @example
@@ -60,14 +68,14 @@ const iterable_queue_1 = require("./iterable-queue");
60
68
  *
61
69
  * @example
62
70
  *
63
- * ### Using `IterableMapper` as Prefetcher with Blocking Sequential Writes
71
+ * ### Prefetching with `IterableMapper` and Blocking Sequential Writes
64
72
  *
65
- * `concurrency: 1` on the prefetcher preserves the order of the reads and and writes are sequential and blocking (unchanged).
73
+ * `concurrency: 1` on the prefetcher preserves the order of the reads, and writes remain sequential and blocking.
66
74
  *
67
75
  * ```typescript
68
76
  * const source = new SomeSource();
69
77
  * const sourceIds = [1, 2,... 1000];
70
- * // Pre-reads up to 8 items serially and releases in sequential order
78
+ * // Prefetches serially within maxUnread and releases results in sequential order
71
79
  * const sourcePrefetcher = new IterableMapper(sourceIds,
72
80
  * async (sourceId) => source.read(sourceId),
73
81
  * { concurrency: 1, maxUnread: 10 }
@@ -83,7 +91,7 @@ const iterable_queue_1 = require("./iterable-queue");
83
91
  *
84
92
  * @example
85
93
  *
86
- * ### Using `IterableMapper` as Prefetcher with Background Sequential Writes with `IterableQueueMapperSimple`
94
+ * ### Prefetching with `IterableMapper` and Background Sequential Writes with `IterableQueueMapperSimple`
87
95
  *
88
96
  * `concurrency: 1` on the prefetcher preserves the order of the reads.
89
97
  * `concurrency: 1` on the flusher preserves the order of the writes, but allows the loop to iterate while last write is completing.
@@ -104,7 +112,7 @@ const iterable_queue_1 = require("./iterable-queue");
104
112
  * const outputItem = doSomeOperation(item); // takes 20 ms of CPU
105
113
  * await flusher.enqueue(outputItem); // will periodically block for portion of write time
106
114
  * }
107
- * // Wait for all writes to complete
115
+ * // Close input permanently after the last enqueue and wait for all writes
108
116
  * await flusher.onIdle();
109
117
  * // Check for errors
110
118
  * if (flusher.errors.length > 0) {
@@ -119,7 +127,7 @@ const iterable_queue_1 = require("./iterable-queue");
119
127
  *
120
128
  * @example
121
129
  *
122
- * ### Using `IterableMapper` as Prefetcher with Out of Order Reads and Background Out of Order Writes with `IterableQueueMapperSimple`
130
+ * ### Prefetching with `IterableMapper` and Out of Order Background Writes with `IterableQueueMapperSimple`
123
131
  *
124
132
  * For maximum throughput, allow out of order reads and writes with
125
133
  * `IterableQueueMapper` (to iterate results with backpressure when too many unread items) or
@@ -141,7 +149,7 @@ const iterable_queue_1 = require("./iterable-queue");
141
149
  * const outputItem = doSomeOperation(item); // takes 20 ms of CPU
142
150
  * await flusher.enqueue(outputItem); // typically will not block
143
151
  * }
144
- * // Wait for all writes to complete
152
+ * // Close input permanently after the last enqueue and wait for all writes
145
153
  * await flusher.onIdle();
146
154
  * // Check for errors
147
155
  * if (flusher.errors.length > 0) {
@@ -163,7 +171,7 @@ class IterableMapper {
163
171
  * @param mapper Function called for every item in `input`. Returns a `Promise` or value.
164
172
  * @param options IterableMapper options
165
173
  *
166
- * @see {@link IterableQueueMapper} for full class documentation
174
+ * @see {@link IterableMapper} for full class documentation
167
175
  */
168
176
  constructor(input, mapper, options = {}) {
169
177
  this._errors = [];
@@ -180,12 +188,6 @@ class IterableMapper {
180
188
  if (typeof mapper !== 'function') {
181
189
  throw new TypeError('Mapper function is required');
182
190
  }
183
- // Avoid undefined errors on options
184
- if (this._options.concurrency === undefined ||
185
- this._options.stopOnMapperError === undefined ||
186
- this._options.maxUnread === undefined) {
187
- throw new TypeError('Options are malformed after init');
188
- }
189
191
  // Validate concurrency option
190
192
  if (!((Number.isSafeInteger(this._options.concurrency) ||
191
193
  this._options.concurrency === Number.POSITIVE_INFINITY) &&
@@ -248,7 +250,7 @@ class IterableMapper {
248
250
  if (!this._options.stopOnMapperError && this._errors.length > 0) {
249
251
  // throw the errors as an aggregate exception
250
252
  this._isRejected = true;
251
- throw new AggregateError(this._errors);
253
+ throw new aggregate_error_1.default(this._errors);
252
254
  }
253
255
  return { value: undefined, done };
254
256
  }
@@ -265,7 +267,7 @@ class IterableMapper {
265
267
  bubbleUpErrors() {
266
268
  if (!this._options.stopOnMapperError && this._errors.length > 0) {
267
269
  // throw the errors as an aggregate exception
268
- throw new AggregateError(this._errors);
270
+ throw new aggregate_error_1.default(this._errors);
269
271
  }
270
272
  }
271
273
  startARunnerIfNeeded() {
@@ -280,34 +282,15 @@ class IterableMapper {
280
282
  if (this._activeRunners < this._options.concurrency) {
281
283
  // We only create runners if we're under the concurrency limit
282
284
  if (this._unreadQueue.length + this._activeRunners <= this._options.maxUnread) {
283
- // We only create runners if the number of runners + unread items will not
284
- // exceed the unread queue length
285
- // Start another source runner, but do not await it
286
- this.startAnotherRunner();
285
+ // The eligibility checks above and reservation below run synchronously.
286
+ // Reserve the slot before starting asynchronous source work.
287
+ this._activeRunners++;
288
+ void this.sourceNext();
287
289
  }
288
290
  }
289
291
  }
290
292
  }
291
293
  }
292
- startAnotherRunner() {
293
- if (this._activeRunners === this._options.concurrency) {
294
- throw new TypeError('active runners would be greater than concurrency limit');
295
- }
296
- if (this._activeRunners + this._unreadQueue.length > this._options.maxUnread) {
297
- throw new TypeError('active runners would overflow the read queue limit');
298
- }
299
- if (this._isIterableDone) {
300
- throw new TypeError('runner should not be started when iterable is already done');
301
- }
302
- if (this._activeRunners < 0) {
303
- throw new TypeError('active runners is less than 0');
304
- }
305
- // We only create runners if the number of runners + unread items will not
306
- // exceed the unread queue length
307
- this._activeRunners++;
308
- // Start another source runner, but do not await it
309
- void this.sourceNext();
310
- }
311
294
  areWeDone() {
312
295
  if (this._isIterableDone) {
313
296
  // The source iterable has no more items
@@ -1 +1 @@
1
- {"version":3,"file":"iterable-mapper.js","sourceRoot":"","sources":["../../src/iterable-mapper.ts"],"names":[],"mappings":";;;AAAA,EAAE;AACF,sGAAsG;AACtG,EAAE;AACF,8DAA8D;AAC9D,MAAM,cAAc,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAClD,qDAAiD;AA8EjD;;;;;;;;;;;;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G,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC;gBAC7E,IAAI,CAAC,cAAc,EAAE,CAAC;gBACtB,OAAO;YACT,CAAC;YAED,qBAAqB;YACrB,wEAAwE;YACxE,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;QAC1B,CAAC,CAAC,EAAE,CAAC;IACP,CAAC;CACF;AAtUD,wCAsUC"}
@@ -6,22 +6,25 @@ type Errors<T> = {
6
6
  } | Error;
7
7
  }[];
8
8
  /**
9
- * Options for IterableQueueMapperSimple
9
+ * Options for `IterableQueueMapperSimple`, also exported as `WorkerQueueOptions`.
10
10
  */
11
11
  export type IterableQueueMapperSimpleOptions = Pick<IterableMapperOptions, 'concurrency'>;
12
12
  /**
13
13
  * Accepts queue items via `enqueue` and calls the `mapper` on them
14
14
  * with specified `concurrency`, discards the results, and accumulates
15
- * exceptions in the `errors` property. When empty, `await enqueue()`
16
- * will return immediately, but when `concurrency` items are in progress,
17
- * `await enqueue()` will block until a slot is available to accept the item.
15
+ * exceptions in the `errors` property. Await `enqueue()` for producer
16
+ * backpressure while the worker callback runs asynchronously.
17
+ *
18
+ * Also exported as `WorkerQueue`, with the same constructor and instance types.
19
+ * Each input uses the same worker callback supplied at construction. Asynchronous
20
+ * work overlaps in the current JavaScript process, and results are consumed internally.
18
21
  *
19
22
  * @remarks
20
23
  *
21
- * ### Typical Use Case
22
- * - Pushing items to an async I/O destination
23
- * - In the simple sequential (`concurrency: 1`) case, allows 1 item to be flushed async while caller prepares next item
24
- * - Results of the flushed items are not needed in a subsequent step (if they are, use `IterableQueueMapper`)
24
+ * ### Typical Use Cases
25
+ * - Running background status checks or other queued work through a fixed callback
26
+ * - Sending items to an async I/O destination
27
+ * - Processing items whose return values can be discarded (if results are needed, use `IterableQueueMapper` / `MappingQueue`)
25
28
  *
26
29
  * ### Error Handling
27
30
  * The mapper should ideally handle all errors internally to enable error handling
@@ -31,7 +34,7 @@ export type IterableQueueMapperSimpleOptions = Pick<IterableMapperOptions, 'conc
31
34
  * - Errors can be checked/handled during processing via the `errors` property
32
35
  *
33
36
  * Key Differences from `IterableQueueMapper`:
34
- * - `maxUnread` defaults to equal `concurrency` (simplifying queue management)
37
+ * - The internal `maxUnread` limit equals `concurrency`; only `concurrency` is configurable
35
38
  * - Results are automatically iterated and discarded (all work should happen in mapper)
36
39
  * - Errors are collected rather than thrown (available via errors property)
37
40
  *
@@ -39,7 +42,11 @@ export type IterableQueueMapperSimpleOptions = Pick<IterableMapperOptions, 'conc
39
42
  * - Items are added to the queue via the `await enqueue()` method
40
43
  * - Check `errors` property to see if any errors occurred, stop if desired
41
44
  * - IMPORTANT: `await enqueue()` method will block until a slot is available, if queue is full
42
- * - IMPORTANT: Always `await onIdle()` to ensure all items are processed
45
+ * - After the last awaited enqueue, await `onIdle()` to close input permanently and finish accepted work
46
+ * - Subsequent enqueues reject, so `onIdle()` is a final shutdown operation
47
+ * - Worker failures are collected in `errors`; they do not reject `onIdle()`
48
+ * - Await each enqueue for producer backpressure; unawaited calls can accumulate pending inputs
49
+ * - Admission limits for event callbacks, cancellation, and per-item completion handles belong to the caller
43
50
  *
44
51
  * Note: the name is somewhat of a misnomer as this wraps `IterableQueueMapper`
45
52
  * but is not itself an `Iterable`.
@@ -70,7 +77,7 @@ export declare class IterableQueueMapperSimple<Element> {
70
77
  private discardResults;
71
78
  private worker;
72
79
  /**
73
- * Accumulated errors from background `mappers`s
80
+ * Accumulated errors from the worker callback.
74
81
  *
75
82
  * @remarks
76
83
  *
@@ -83,24 +90,24 @@ export declare class IterableQueueMapperSimple<Element> {
83
90
  */
84
91
  get errors(): Errors<Element>;
85
92
  /**
86
- * Accept a request for sending in the background if a concurrency slot is available.
87
- * Else, do not return until a concurrency slot is freed up.
88
- * This provides concurrency background writes with backpressure to prevent
89
- * the caller from getting too far ahead.
93
+ * Accept an input for the worker callback, waiting until it can be accepted.
94
+ * Resolves on acceptance, rather than completion of this item's work.
95
+ * Await each enqueue for producer backpressure.
90
96
  *
91
- * MUST await `onIdle` for background `mappers`s to finish
92
- * @param item
97
+ * After the last enqueue, await `onIdle()` to close input and finish accepted work.
98
+ * @param item Input for the worker callback
93
99
  */
94
100
  enqueue(item: Element): Promise<void>;
95
101
  /**
96
- * Wait for all background `mapper`s to finish.
97
- * MUST be called before exit to ensure no lost writes.
102
+ * Permanently close input and wait for all accepted work to finish.
103
+ * Call after the last awaited enqueue. Subsequent enqueues reject.
104
+ * Worker failures are available in `errors` instead of rejecting this wait.
98
105
  */
99
106
  onIdle(): Promise<void>;
100
107
  /**
101
- * Indicates if all background `mapper`s have finished.
108
+ * Indicates whether final shutdown has completed.
102
109
  *
103
- * @returns true if .onIdle() has been called and finished all background writes
110
+ * @returns true after `onIdle()` has finished all accepted work and closed input
104
111
  */
105
112
  get isIdle(): boolean;
106
113
  }
@@ -6,16 +6,19 @@ const NoResult = Symbol('noresult');
6
6
  /**
7
7
  * Accepts queue items via `enqueue` and calls the `mapper` on them
8
8
  * with specified `concurrency`, discards the results, and accumulates
9
- * exceptions in the `errors` property. When empty, `await enqueue()`
10
- * will return immediately, but when `concurrency` items are in progress,
11
- * `await enqueue()` will block until a slot is available to accept the item.
9
+ * exceptions in the `errors` property. Await `enqueue()` for producer
10
+ * backpressure while the worker callback runs asynchronously.
11
+ *
12
+ * Also exported as `WorkerQueue`, with the same constructor and instance types.
13
+ * Each input uses the same worker callback supplied at construction. Asynchronous
14
+ * work overlaps in the current JavaScript process, and results are consumed internally.
12
15
  *
13
16
  * @remarks
14
17
  *
15
- * ### Typical Use Case
16
- * - Pushing items to an async I/O destination
17
- * - In the simple sequential (`concurrency: 1`) case, allows 1 item to be flushed async while caller prepares next item
18
- * - Results of the flushed items are not needed in a subsequent step (if they are, use `IterableQueueMapper`)
18
+ * ### Typical Use Cases
19
+ * - Running background status checks or other queued work through a fixed callback
20
+ * - Sending items to an async I/O destination
21
+ * - Processing items whose return values can be discarded (if results are needed, use `IterableQueueMapper` / `MappingQueue`)
19
22
  *
20
23
  * ### Error Handling
21
24
  * The mapper should ideally handle all errors internally to enable error handling
@@ -25,7 +28,7 @@ const NoResult = Symbol('noresult');
25
28
  * - Errors can be checked/handled during processing via the `errors` property
26
29
  *
27
30
  * Key Differences from `IterableQueueMapper`:
28
- * - `maxUnread` defaults to equal `concurrency` (simplifying queue management)
31
+ * - The internal `maxUnread` limit equals `concurrency`; only `concurrency` is configurable
29
32
  * - Results are automatically iterated and discarded (all work should happen in mapper)
30
33
  * - Errors are collected rather than thrown (available via errors property)
31
34
  *
@@ -33,7 +36,11 @@ const NoResult = Symbol('noresult');
33
36
  * - Items are added to the queue via the `await enqueue()` method
34
37
  * - Check `errors` property to see if any errors occurred, stop if desired
35
38
  * - IMPORTANT: `await enqueue()` method will block until a slot is available, if queue is full
36
- * - IMPORTANT: Always `await onIdle()` to ensure all items are processed
39
+ * - After the last awaited enqueue, await `onIdle()` to close input permanently and finish accepted work
40
+ * - Subsequent enqueues reject, so `onIdle()` is a final shutdown operation
41
+ * - Worker failures are collected in `errors`; they do not reject `onIdle()`
42
+ * - Await each enqueue for producer backpressure; unawaited calls can accumulate pending inputs
43
+ * - Admission limits for event callbacks, cancellation, and per-item completion handles belong to the caller
37
44
  *
38
45
  * Note: the name is somewhat of a misnomer as this wraps `IterableQueueMapper`
39
46
  * but is not itself an `Iterable`.
@@ -66,7 +73,6 @@ class IterableQueueMapperSimple {
66
73
  this._done = this.discardResults();
67
74
  }
68
75
  async discardResults() {
69
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
70
76
  let item = await this._writer.next();
71
77
  while (item.done !== true) {
72
78
  // Just discard all the results
@@ -85,7 +91,7 @@ class IterableQueueMapperSimple {
85
91
  return NoResult;
86
92
  }
87
93
  /**
88
- * Accumulated errors from background `mappers`s
94
+ * Accumulated errors from the worker callback.
89
95
  *
90
96
  * @remarks
91
97
  *
@@ -100,34 +106,34 @@ class IterableQueueMapperSimple {
100
106
  return this._errors;
101
107
  }
102
108
  /**
103
- * Accept a request for sending in the background if a concurrency slot is available.
104
- * Else, do not return until a concurrency slot is freed up.
105
- * This provides concurrency background writes with backpressure to prevent
106
- * the caller from getting too far ahead.
109
+ * Accept an input for the worker callback, waiting until it can be accepted.
110
+ * Resolves on acceptance, rather than completion of this item's work.
111
+ * Await each enqueue for producer backpressure.
107
112
  *
108
- * MUST await `onIdle` for background `mappers`s to finish
109
- * @param item
113
+ * After the last enqueue, await `onIdle()` to close input and finish accepted work.
114
+ * @param item Input for the worker callback
110
115
  */
111
116
  async enqueue(item) {
112
- // Return immediately or wait for a slot to free up in the background writer
117
+ // Return immediately or wait for the underlying mapping queue to accept the input
113
118
  await this._writer.enqueue(item);
114
119
  }
115
120
  /**
116
- * Wait for all background `mapper`s to finish.
117
- * MUST be called before exit to ensure no lost writes.
121
+ * Permanently close input and wait for all accepted work to finish.
122
+ * Call after the last awaited enqueue. Subsequent enqueues reject.
123
+ * Worker failures are available in `errors` instead of rejecting this wait.
118
124
  */
119
125
  async onIdle() {
120
126
  if (this._isIdle)
121
127
  return;
122
- // Indicate that we're done writing requests
128
+ // Indicate that no more inputs will be enqueued
123
129
  this._writer.done();
124
130
  await this._done;
125
131
  this._isIdle = true;
126
132
  }
127
133
  /**
128
- * Indicates if all background `mapper`s have finished.
134
+ * Indicates whether final shutdown has completed.
129
135
  *
130
- * @returns true if .onIdle() has been called and finished all background writes
136
+ * @returns true after `onIdle()` has finished all accepted work and closed input
131
137
  */
132
138
  get isIdle() {
133
139
  return this._isIdle;
@@ -1 +1 @@
1
- {"version":3,"file":"iterable-queue-mapper-simple.js","sourceRoot":"","sources":["../../src/iterable-queue-mapper-simple.ts"],"names":[],"mappings":";;;AACA,mEAA8D;AAK9D,MAAM,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;AAOpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAa,yBAAyB;IAOpC;;;;;;;;;;OAUG;IACH,YAAY,MAA6B,EAAE,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IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QACrC,OAAO,IAAI,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;YAC1B,+BAA+B;YAC/B,oEAAoE;YACpE,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QACnC,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,MAAM,CAAC,IAAa,EAAE,KAAa;QAC/C,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;YAChC,8DAA8D;QAChE,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QACrC,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;;;;;;;;OAWG;IACH,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;;;;;;;OAOG;IACI,KAAK,CAAC,OAAO,CAAC,IAAa;QAChC,kFAAkF;QAClF,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,MAAM;QACjB,IAAI,IAAI,CAAC,OAAO;YAAE,OAAO;QAEzB,gDAAgD;QAChD,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QAEpB,MAAM,IAAI,CAAC,KAAK,CAAC;QAEjB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;IACtB,CAAC;IAED;;;;OAIG;IACH,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF;AArGD,8DAqGC"}
@@ -1,6 +1,6 @@
1
1
  import { IterableMapperOptions, Mapper } from './iterable-mapper';
2
2
  /**
3
- * Options for IterableQueueMapper
3
+ * Options for `IterableQueueMapper`, also exported as `MappingQueueOptions`.
4
4
  */
5
5
  export type IterableQueueMapperOptions = IterableMapperOptions;
6
6
  /**
@@ -9,12 +9,16 @@ export type IterableQueueMapperOptions = IterableMapperOptions;
9
9
  * of `maxUnread` size, before being iterated / read by the caller.
10
10
  * The `enqueue` method will block if the queue is full, until an item is read.
11
11
  *
12
+ * Also exported as `MappingQueue`, with the same constructor and instance types.
13
+ * Each input uses the same callback supplied at construction; results are exposed
14
+ * through the async iterator as mapping completes.
15
+ *
12
16
  * @remarks
13
17
  *
14
- * ### Typical Use Case
15
- * - Pushing items to an async I/O destination
16
- * - In the simple sequential (`concurrency: 1`) case, allows 1 item to be flushed async while caller prepares next item
17
- * - Results of the flushed items are needed in a subsequent step (if they are not, use `IterableQueueMapperSimple`)
18
+ * ### Typical Use Cases
19
+ * - Enqueuing capability probes or metadata lookups as inputs become available
20
+ * - Sending items to an async I/O destination and consuming its acknowledgements
21
+ * - Consuming mapped results in a subsequent step (if results can be discarded, use `IterableQueueMapperSimple` / `WorkerQueue`)
18
22
  * - Prevents the producer from racing ahead of the consumer if `maxUnread` is reached
19
23
  *
20
24
  * ### Error Handling
@@ -33,8 +37,10 @@ export type IterableQueueMapperOptions = IterableMapperOptions;
33
37
  * ### Usage
34
38
  * - Items are added to the queue via the `await enqueue()` method
35
39
  * - IMPORTANT: `await enqueue()` method will block until a slot is available, if queue is full
36
- * - Call `done()` when no more items will be enqueued
37
- * - IMPORTANT: Always `await onIdle()` to ensure all items are processed
40
+ * - Produce inputs and consume results concurrently so the result buffer can drain
41
+ * - Call `done()` after the last awaited enqueue, then finish consuming the iterator
42
+ * - `enqueue()` confirms acceptance of an input; `done()` closes input without waiting for work to finish
43
+ * - Await each enqueue for producer backpressure; unawaited calls can accumulate pending inputs
38
44
  *
39
45
  * @category Enqueue Input
40
46
  *
@@ -62,7 +68,9 @@ export declare class IterableQueueMapper<Element, NewElement> implements AsyncIt
62
68
  */
63
69
  next(): Promise<IteratorResult<NewElement>>;
64
70
  /**
65
- * Add an item to the queue, wait if the queue is full.
71
+ * Add an item to the queue, waiting until it can be accepted.
72
+ * Resolves on acceptance, rather than completion of the mapper for this item.
73
+ * Await each enqueue while consuming results concurrently for producer backpressure.
66
74
  *
67
75
  * @param item Element to add
68
76
  */
@@ -70,7 +78,8 @@ export declare class IterableQueueMapper<Element, NewElement> implements AsyncIt
70
78
  /**
71
79
  * Indicate that no more items will be enqueued.
72
80
  *
73
- * This releases all readers blocked on `enqueue`
81
+ * Call after the last awaited enqueue. Finish consuming the async iterator
82
+ * to wait for mapped results; this method does not wait for processing to finish.
74
83
  */
75
84
  done(): void;
76
85
  }
@@ -12,12 +12,16 @@ const iterable_queue_1 = require("./iterable-queue");
12
12
  * of `maxUnread` size, before being iterated / read by the caller.
13
13
  * The `enqueue` method will block if the queue is full, until an item is read.
14
14
  *
15
+ * Also exported as `MappingQueue`, with the same constructor and instance types.
16
+ * Each input uses the same callback supplied at construction; results are exposed
17
+ * through the async iterator as mapping completes.
18
+ *
15
19
  * @remarks
16
20
  *
17
- * ### Typical Use Case
18
- * - Pushing items to an async I/O destination
19
- * - In the simple sequential (`concurrency: 1`) case, allows 1 item to be flushed async while caller prepares next item
20
- * - Results of the flushed items are needed in a subsequent step (if they are not, use `IterableQueueMapperSimple`)
21
+ * ### Typical Use Cases
22
+ * - Enqueuing capability probes or metadata lookups as inputs become available
23
+ * - Sending items to an async I/O destination and consuming its acknowledgements
24
+ * - Consuming mapped results in a subsequent step (if results can be discarded, use `IterableQueueMapperSimple` / `WorkerQueue`)
21
25
  * - Prevents the producer from racing ahead of the consumer if `maxUnread` is reached
22
26
  *
23
27
  * ### Error Handling
@@ -36,8 +40,10 @@ const iterable_queue_1 = require("./iterable-queue");
36
40
  * ### Usage
37
41
  * - Items are added to the queue via the `await enqueue()` method
38
42
  * - IMPORTANT: `await enqueue()` method will block until a slot is available, if queue is full
39
- * - Call `done()` when no more items will be enqueued
40
- * - IMPORTANT: Always `await onIdle()` to ensure all items are processed
43
+ * - Produce inputs and consume results concurrently so the result buffer can drain
44
+ * - Call `done()` after the last awaited enqueue, then finish consuming the iterator
45
+ * - `enqueue()` confirms acceptance of an input; `done()` closes input without waiting for work to finish
46
+ * - Await each enqueue for producer backpressure; unawaited calls can accumulate pending inputs
41
47
  *
42
48
  * @category Enqueue Input
43
49
  *
@@ -72,7 +78,9 @@ class IterableQueueMapper {
72
78
  return this._iterableMapper.next();
73
79
  }
74
80
  /**
75
- * Add an item to the queue, wait if the queue is full.
81
+ * Add an item to the queue, waiting until it can be accepted.
82
+ * Resolves on acceptance, rather than completion of the mapper for this item.
83
+ * Await each enqueue while consuming results concurrently for producer backpressure.
76
84
  *
77
85
  * @param item Element to add
78
86
  */
@@ -82,7 +90,8 @@ class IterableQueueMapper {
82
90
  /**
83
91
  * Indicate that no more items will be enqueued.
84
92
  *
85
- * This releases all readers blocked on `enqueue`
93
+ * Call after the last awaited enqueue. Finish consuming the async iterator
94
+ * to wait for mapped results; this method does not wait for processing to finish.
86
95
  */
87
96
  done() {
88
97
  this._sourceIterable.done();
@@ -1 +1 @@
1
- {"version":3,"file":"iterable-queue-mapper.js","sourceRoot":"","sources":["../../src/iterable-queue-mapper.ts"],"names":[],"mappings":";;;AAAA,EAAE;AACF,sGAAsG;AACtG,EAAE;AACF,uDAAkF;AAClF,qDAAiD;AAOjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAa,mBAAmB;IAK9B;;;;;;;;;OASG;IACH,YAAY,MAAmC,EAAE,UAAsC,EAAE;QACvF,IAAI,CAAC,eAAe,GAAG,IAAI,8BAAa,CAAC;YACvC,SAAS,EAAE,CAAC;SACb,CAAC,CAAC;QACH,IAAI,CAAC,eAAe,GAAG,IAAI,gCAAc,CAAC,IAAI,CAAC,eAAe,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IACnF,CAAC;IAEM,CAAC,MAAM,CAAC,aAAa,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,IAAI;QACf,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC;IACrC,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,OAAO,CAAC,IAAa;QAChC,MAAM,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3C,CAAC;IAED;;;;OAIG;IACI,IAAI;QACT,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC;IAC9B,CAAC;CACF;AApDD,kDAoDC"}
1
+ {"version":3,"file":"iterable-queue-mapper.js","sourceRoot":"","sources":["../../src/iterable-queue-mapper.ts"],"names":[],"mappings":";;;AAAA,EAAE;AACF,sGAAsG;AACtG,EAAE;AACF,uDAAkF;AAClF,qDAAiD;AAOjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,MAAa,mBAAmB;IAK9B;;;;;;;;;OASG;IACH,YAAY,MAAmC,EAAE,UAAsC,EAAE;QACvF,IAAI,CAAC,eAAe,GAAG,IAAI,8BAAa,CAAC;YACvC,SAAS,EAAE,CAAC;SACb,CAAC,CAAC;QACH,IAAI,CAAC,eAAe,GAAG,IAAI,gCAAc,CAAC,IAAI,CAAC,eAAe,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IACnF,CAAC;IAEM,CAAC,MAAM,CAAC,aAAa,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,IAAI;QACf,OAAO,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC;IACrC,CAAC;IAED;;;;;;OAMG;IACI,KAAK,CAAC,OAAO,CAAC,IAAa;QAChC,MAAM,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3C,CAAC;IAED;;;;;OAKG;IACI,IAAI;QACT,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC;IAC9B,CAAC;CACF;AAvDD,kDAuDC"}
@@ -1 +1 @@
1
- {"version":3,"file":"iterable-queue.js","sourceRoot":"","sources":["../../src/iterable-queue.ts"],"names":[],"mappings":";;;AAAA,qDAAuE;AAIvE;;;;GAIG;AACH,MAAa,aACX,SAAQ,8BAAsB;IAG9B;;;OAGG;IACH,YAAY,UAAgC,EAAE;QAC5C,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;IAEM,CAAC,MAAM,CAAC,aAAa,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,IAAI;QACf,6BAA6B;QAC7B,MAAM,IAAI,GAAwB,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;QAEvD,IAAI,IAAI,KAAK,SAAS,EAAE;YACtB,yCAAyC;YACzC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;SACzC;QAED,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;IACtC,CAAC;CACF;AAjCD,sCAiCC"}
1
+ {"version":3,"file":"iterable-queue.js","sourceRoot":"","sources":["../../src/iterable-queue.ts"],"names":[],"mappings":";;;AAAA,qDAAuE;AAIvE;;;;GAIG;AACH,MAAa,aACX,SAAQ,8BAAsB;IAG9B;;;OAGG;IACH,YAAY,UAAgC,EAAE;QAC5C,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;IAEM,CAAC,MAAM,CAAC,aAAa,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,IAAI;QACf,6BAA6B;QAC7B,MAAM,IAAI,GAAwB,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;QAEvD,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,yCAAyC;YACzC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;QAC1C,CAAC;QAED,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;IACtC,CAAC;CACF;AAjCD,sCAiCC"}
@@ -1 +1 @@
1
- {"version":3,"file":"queue.js","sourceRoot":"","sources":["../../src/queue.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,kGAAkG;AAClG,EAAE;;;AAEF;;;;GAIG;AACH,MAAa,KAAK;IAAlB;QACU,WAAM,GAA2B,EAAE,CAAC;QACpC,UAAK,GAAG,CAAC,CAAC;QACV,UAAK,GAAG,CAAC,CAAC;IAsBpB,CAAC;IApBC,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;IACjC,CAAC;IAED,0CAA0C;IACnC,OAAO,CAAC,OAAU;QACvB,IAAI,OAAO,KAAK,SAAS,EAAE;YACzB,MAAM,IAAI,SAAS,CAAC,4BAA4B,CAAC,CAAC;SACnD;QACD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC;IACtC,CAAC;IAED,yCAAyC;IAClC,OAAO;QACZ,IAAI,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,KAAK;YAAE,OAAO,SAAS,CAAC;QAEhD,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACxC,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QACjC,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AAzBD,sBAyBC"}
1
+ {"version":3,"file":"queue.js","sourceRoot":"","sources":["../../src/queue.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,kGAAkG;AAClG,EAAE;;;AAEF;;;;GAIG;AACH,MAAa,KAAK;IAAlB;QACU,WAAM,GAA2B,EAAE,CAAC;QACpC,UAAK,GAAG,CAAC,CAAC;QACV,UAAK,GAAG,CAAC,CAAC;IAsBpB,CAAC;IApBC,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;IACjC,CAAC;IAED,0CAA0C;IACnC,OAAO,CAAC,OAAU;QACvB,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,MAAM,IAAI,SAAS,CAAC,4BAA4B,CAAC,CAAC;QACpD,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC;IACtC,CAAC;IAED,yCAAyC;IAClC,OAAO;QACZ,IAAI,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,KAAK;YAAE,OAAO,SAAS,CAAC;QAEhD,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACxC,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QACjC,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AAzBD,sBAyBC"}
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@shutterstock/p-map-iterable",
3
- "version": "1.1.2",
4
- "description": "Set of classes used for async prefetching with backpressure (IterableMapper) and async flushing with backpressure (IterableQueueMapper, IterableQueueMapperSimple)",
3
+ "version": "1.2.0",
4
+ "packageManager": "pnpm@12.7.0",
5
+ "description": "Concurrent mapping and queued background work with backpressure, streaming results, and collected errors",
5
6
  "main": "dist/src/index.js",
6
7
  "types": "dist/src/index.d.ts",
7
8
  "publishConfig": {
@@ -29,9 +30,10 @@
29
30
  "example:iterable-mapper": "ts-node -r tsconfig-paths/register examples/iterable-mapper.ts",
30
31
  "example:iterable-queue-mapper": "ts-node -r tsconfig-paths/register examples/iterable-queue-mapper.ts",
31
32
  "example:iterable-queue-mapper-simple": "ts-node -r tsconfig-paths/register examples/iterable-queue-mapper-simple.ts",
33
+ "example:semantic-aliases": "ts-node -r tsconfig-paths/register examples/semantic-aliases.ts",
32
34
  "test": "jest",
33
- "lint": "eslint ./ --ext .ts --ext .tsx",
34
- "lint-and-fix": "eslint ./ --ext .ts --ext .tsx --fix"
35
+ "lint": "eslint .",
36
+ "lint-and-fix": "eslint . --fix"
35
37
  },
36
38
  "files": [
37
39
  "dist/",
@@ -44,24 +46,28 @@
44
46
  },
45
47
  "license": "MIT",
46
48
  "dependencies": {
47
- "aggregate-error": "^3.0.0"
49
+ "aggregate-error": "^3.1.0"
48
50
  },
49
51
  "peerDependencies": {
50
- "aggregate-error": "^3.0.0"
52
+ "aggregate-error": "^3.1.0"
51
53
  },
52
54
  "devDependencies": {
53
- "@types/jest": "29.5.2",
54
- "@typescript-eslint/eslint-plugin": "^5.13.0",
55
- "@typescript-eslint/parser": "^5.13.0",
56
- "eslint": "^7.15.0",
57
- "eslint-config-prettier": "^7.0.0",
58
- "eslint-plugin-prettier": "^3.2.0",
59
- "jest": "29.5.0",
60
- "prettier": "^2.2.1",
61
- "ts-jest": "29.1.0",
62
- "ts-node": "10.9.1",
55
+ "@eslint/js": "^10.0.1",
56
+ "@types/jest": "30.0.0",
57
+ "@types/node": "^26.6.3",
58
+ "@typescript-eslint/eslint-plugin": "^8.70.1",
59
+ "@typescript-eslint/parser": "^8.70.1",
60
+ "eslint": "^10.11.0",
61
+ "eslint-config-prettier": "^10.1.8",
62
+ "eslint-plugin-prettier": "^5.5.6",
63
+ "globals": "^17.12.0",
64
+ "jest": "30.5.2",
65
+ "lcov-parse": "1.0.0",
66
+ "prettier": "^3.9.9",
67
+ "ts-jest": "29.4.14",
68
+ "ts-node": "10.9.2",
63
69
  "tsconfig-paths": "4.2.0",
64
- "typedoc": "^0.24.8",
65
- "typescript": "5.1.3"
70
+ "typedoc": "^0.28.20",
71
+ "typescript": "6.0.3"
66
72
  }
67
73
  }