ts-iterable-functions
    Preparing search index...

    Function _aggregate

    • Aggregates all elements from the source iterable into a single value using the provided accumulator.

      Type Parameters

      • T

        Element type produced by the source iterable.

      • TOut

        Accumulator result type yielded after processing the entire sequence.

      Parameters

      • src: Iterable<T>

        Source iterable whose elements will feed into the accumulator function.

      • seed: TOut

        Initial accumulator value supplied to the first call of aggFunc.

      • aggFunc: (prev: TOut, curr: T, idx: number) => TOut

        Combiner invoked with the previous accumulator, current element, and current index.

      Returns TOut

      The final accumulator value after iterating through the entire source.

      const total = _aggregate([1, 2, 3], 0, (acc, n) => acc + n);
      console.log(total); // 6

      or using the curried version:

      const total = pipeInto(
      [1, 2, 3],
      aggregate(0, (acc, n) => acc + n)
      );
      console.log(total); // 6