Exposes the source iterable to an external consumer, and emits a one-value iterable with that consumer.
It is to simplify integration with external API that consumes iterables.
import {pipeAsync, consume} from 'iter-ops';import {Readable} from 'stream';const i = pipeAsync( [1, 2, 3, 4, 5], consume(source => Readable.from(source))); //=> AsyncIterableExt<Readable>const r = await i.first; //=> Readable stream Copy
import {pipeAsync, consume} from 'iter-ops';import {Readable} from 'stream';const i = pipeAsync( [1, 2, 3, 4, 5], consume(source => Readable.from(source))); //=> AsyncIterableExt<Readable>const r = await i.first; //=> Readable stream
The consumer callback can optionally return a Promise when inside asynchronous pipeline.
Promise
Flag sync in the callback is true when the iterable is synchronous, and false when asynchronous.
sync
true
false
Exposes the source iterable to an external consumer, and emits a one-value iterable with that consumer.
It is to simplify integration with external API that consumes iterables.
The consumer callback can optionally return a
Promise
when inside asynchronous pipeline.Flag
sync
in the callback istrue
when the iterable is synchronous, andfalse
when asynchronous.