mapSequence()function
mapSequence(sequence: AsyncIterable<I>, transform: (input: I, ...args: A) => O | PromiseLike<O>, ...args: A): AsyncIterable<O>
| Param | Type | |
|---|---|---|
sequence | AsyncIterable<I> | The source async iterable of items. required |
transform | (input: I, ...args: A) => OPromiseLike<O> | Function applied to each item to produce the output item (may be async). required |
args | A | Additional arguments passed through to transform on every call. required |
| Return | |
|---|---|
AsyncIterable<O> | An async iterable yielding each transformed item. |
Lazily transform items in an async sequence as they are yielded.
- The transform may be synchronous or return a promise; awaited values are yielded in order.
Examples
for await (const n of mapSequence(source, x => x * 2)) use(n);