yta
    Preparing search index...

    Function reduce

    • Consume the iterator resulting in a single value.

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

      pipe(
      range(10),
      reduce((sum, x) => sum + x, 0),
      );
      // => 45

      See also:

      Type Parameters

      • A

        The input type

      • B

        The output value type

      Parameters

      • fn: (acc: B, item: A) => B

        The consuming function

      • init: B

        The initial value

      Returns (items: Iterable<A>) => B