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

    Function filter

    • Creates a task retaining only the items matching a predicate.

      Items are tested lazily, one at a time, and emitted in source order.

      Type Parameters

      • V

        The type of items in the feed

      Parameters

      • predicate: (item: V) => Awaitable<boolean | undefined>

        The function testing each item; an undefined result is treated as false and the item is discarded

      Returns Task<V>

      A task yielding the items matching predicate

      await pipe(
      (items(1, 2, 3, 4, 5))
      (filter(n => n%2 === 0))
      (toArray())
      ); // [2, 4]