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

    Function map

    • Creates a task converting each item into a new value.

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

      Type Parameters

      • V

        The type of input items

      • R

        The type of output items

      Parameters

      • mapper: (item: V) => Awaitable<R | undefined>

        The function converting each item; an undefined result contributes nothing, so mapping doubles as filtering

      Returns Task<V, R>

      A task yielding the values mapper converts the items into

      await pipe(
      (items(1, 2, 3))
      (map(n => n*2))
      (toArray())
      ); // [2, 4, 6]