yta
    Preparing search index...

    Function flatMap

    • Map each item into an iterator and flatten.

      import { pipe } from "yta";
      import { flatMap, range, toArray } from "yta/sync";

      pipe(
      range(4),
      flatMap((n) => range(n)),
      toArray(),
      );
      // => [0, 0, 1, 0, 1, 2]

      See also:

      Type Parameters

      • A

        The input type

      • B

        The output type

      Parameters

      • fn: (item: A) => Iterable<B>

        The mapping function

      Returns (items: Iterable<A>) => Generator<B, void>