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

    Function filter

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

      Items are emitted in source order.

      Note

      • Incremental: items are emitted as they are drawn, so the reported feed runs dry as the feed drawn from does.
      • Streaming: items are tested one at a time, none retained.
      • Stateless: every item is tested on its own, so the outcome is unaffected by how the feed is split across nested feeds or runs.

      Type Parameters

      • V

        The type of items in the feed

      Parameters

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

        The function testing each item

      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]