Create a new IterableQueueMapperSimple, which uses IterableQueueMapper underneath, but
automatically iterates and discards results as they complete.
Function called for every enqueued item. Returns a Promise or value.
IterableQueueMapperSimple options
Indicates whether final shutdown has completed.
true after onIdle() has finished all accepted work and closed input
Accept an input for the worker callback, waiting until it can be accepted. Resolves on acceptance, rather than completion of this item's work. Await each enqueue for producer backpressure.
After the last enqueue, await onIdle() to close input and finish accepted work.
Input for the worker callback
Permanently close input and wait for all accepted work to finish.
Call after the last awaited enqueue. Subsequent enqueues reject.
Worker failures are available in errors instead of rejecting this wait.
Accepts queue items via
enqueueand calls themapperon them with specifiedconcurrency, discards the results, and accumulates exceptions in theerrorsproperty. Awaitenqueue()for producer backpressure while the worker callback runs asynchronously.Also exported as
WorkerQueue, with the same constructor and instance types. Each input uses the same worker callback supplied at construction. Asynchronous work overlaps in the current JavaScript process, and results are consumed internally.Remarks
Typical Use Cases
IterableQueueMapper/MappingQueue)Error Handling
The mapper should ideally handle all errors internally to enable error handling closest to where they occur. However, if errors do escape the mapper:
errorspropertyerrorspropertyKey Differences from
IterableQueueMapper:maxUnreadlimit equalsconcurrency; onlyconcurrencyis configurableUsage
await enqueue()methoderrorsproperty to see if any errors occurred, stop if desiredawait enqueue()method will block until a slot is available, if queue is fullonIdle()to close input permanently and finish accepted workonIdle()is a final shutdown operationerrors; they do not rejectonIdle()Note: the name is somewhat of a misnomer as this wraps
IterableQueueMapperbut is not itself anIterable.See