Create a new IterableQueueMapper
, which uses IterableMapper
underneath, and exposes a
queue interface for adding items that are not exposed via an iterator.
Function called for every enqueued item. Returns a Promise
or value.
IterableQueueMapper options
Private
_iterablePrivate
_sourceGenerated using TypeDoc
Accepts queue items via
enqueue
and calls themapper
on them with specifiedconcurrency
, storing themapper
result in a queue ofmaxUnread
size, before being iterated / read by the caller. Theenqueue
method will block if the queue is full, until an item is read.Remarks
Typical Use Case
concurrency: 1
) case, allows 1 item to be flushed async while caller prepares next itemIterableQueueMapperSimple
)maxUnread
is reachedError 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:
When
stopOnMapperError
is true (default):AsyncIterator
's next() callWhen
stopOnMapperError
is false:AggregateError
after all items completeUsage
await enqueue()
methodawait enqueue()
method will block until a slot is available, if queue is fulldone()
when no more items will be enqueuedawait onIdle()
to ensure all items are processedSee
IterableMapper for underlying mapper implementation and examples of combined usage