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

    Module feeds

    Factory functions that open new feeds from various input sources.

    Feeds open the Feed a pipe is built on, either adapting values and data sources into one ready for task and sink composition, or combining several feeds into a single one, drawn either in sequence or concurrently. Work is deferred until a sink or a manual iteration consumes the feed.

    Caution

    When creating custom feeds, always wrap async generators, async generator functions or AsyncIterable<T> objects with feed to ensure undefined filtering and conformance to the Feed contract.

    Custom Feeds are functions opening a feed over a source of their own:

    import { pipe } from '@metreeca/flow';
    import { feed } 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 feed(async function* () {
    for (let i = 0; i < count; i++) { yield value; }
    }());
    }

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

    Functions

    chain

    Creates a feed concatenating multiple feeds.

    feed

    Creates a feed from a data source.

    items

    Creates a feed from a list of values.

    iterate

    Creates a feed from repeated calls to a generator function.

    merge

    Creates a feed interleaving multiple feeds.

    range

    Creates a feed from a range of consecutive integers.