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

    Module tasks

    Intermediate operations that filter, transform, or process feed items.

    Tasks apply to a Feed and yield a new feed, so they chain freely into longer pipes. Items are processed lazily, sequentially and in source order, unless a task reorders them or wraps another to run it concurrently, trading output order for throughput. Tasks buffering the whole feed in memory never complete on infinite sources.

    Custom Tasks are functions that transform async iterables by returning async generator functions; items to be dropped are left unyielded or yielded as undefined, as feeds never carry it:

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

    function double<V extends number>(): Task<V, V> {
    return async function* (source) {
    for await (const item of source) { yield item*2 as V; }
    };
    }

    await pipe(
    (items(1, 2, 3))
    (double())
    (toArray())
    ); // [2, 4, 6]

    Functions

    batch

    Creates a task collecting consecutive items into fixed-size batches.

    concurrent

    Creates a task interleaving several runs of another task over the same feed.

    distinct

    Creates a task discarding repeated items.

    filter

    Creates a task retaining only the items matching a predicate.

    flatMap

    Creates a task expanding each item into a data source.

    group

    Creates a task collecting items sharing the same key.

    map

    Creates a task converting each item into a new value.

    peek

    Creates a task observing the feed without altering it.

    skip

    Creates a task discarding a prefix of the feed.

    sort

    Creates a task reordering the feed.

    take

    Creates a task truncating the feed to a prefix.