@metreeca/flow - v0.10.0
    Preparing search index...

    Module feeds

    Factory functions that open a feed over values and data sources.

    Feeds open the Feed a pipe is built on, adapting values and data sources into one ready for task and sink composition; several feeds are combined into a single one by carrying them in a feed of their own and splicing it with flat or join. Work is deferred until a sink or a manual iteration consumes the feed.

    Every feed is classified as bounded or infinite: a bounded feed runs dry on its own, while an infinite one has to be bounded downstream, with a task such as take or with a sink deciding its outcome early.

    Note

    A custom feed is only required to honour the Feed contract, however it is assembled: handing the source to items is the shortest route there, as the adapter takes the contract on, while a source that is already a feed honours it as it is. Whichever route is taken, a feed replays only as far as its source does, so one opened from a generator object runs dry after the first pass, while one opened from a repeatable source is consumed afresh at each.

    Custom Feeds open a pipe over a source of your own:

    import { pipe } from '@metreeca/flow';
    import { items } from '@metreeca/flow/feeds';
    import { toArray } from '@metreeca/flow/sinks';
    import type { Feed } from '@metreeca/flow';

    function repeat<V>(value: V, count: number): Feed<V> {
    return items((async function* () {
    for (let i = 0; i < count; i++) { yield value; }
    })());
    }

    await pipe(
    (repeat(42, 3))
    (toArray())
    ); // [42, 42, 42]

    Variables

    done

    The end marker a source reports in place of a value to end the feed opened over it.

    Functions

    inlet

    Creates a feed over an external source of items, drawn one at a time on demand.

    items

    Creates a feed from a data source.

    range

    Creates a feed from a range of consecutive integers.