The type of items drawn from the feed
The type of items the mapper computes
A task yielding the items mapper computes over the feed
await pipe(
(items([1, 2, 3, 4]))
(chain(async feed => (await feed(toArray())).slice(-2)))
(toArray())
); // [3, 4], as the last items are known only once the feed runs dry
await pipe(
(items([1, 2, 2, 3]))
(chain(toSet()))
(toArray())
); // [1, 2, 3], as a sink already available is lifted back into the pipe
Creates a task emitting the items a mapper computes over the feed.
The mapper is handed the feed and computes the items to carry on with, so a step deciding on the feed as a whole, reconciling it against a stored snapshot, ranking it or clearing it against a quota before letting anything through, is written as an ordinary asynchronous function of the feed rather than as a generator of its own. Sinks already available are lifted back into the pipe the same way: handing over toSet carries on with the distinct items alone.
The items are supplied either as a batch listing them or as a feed yielding them, handed back as they are or awaited, so a step composing the feed it draws from with tasks already available is spared the generator as well.
Whatever the mapper computes is emitted item by item, so the items carried on with need be neither the ones drawn, nor as many, nor of the same type: a mapper computing nothing empties the feed, and one computing items of its own emits them even where the feed drew none.
A mapper computing a string emits its characters, as any other iterable does its items: carry a string on whole by wrapping it in an array.