ts-iterable-functions
    Preparing search index...

    Function _scan

    • Produces the intermediate accumulator values of a reduction over the source iterable.

      Type Parameters

      • T

        Element type produced by the source iterable.

      • TOut

        Accumulator result type when a distinct seed is supplied.

      Parameters

      • src: Iterable<T>

        Source iterable providing values for the running aggregation.

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

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

      • seed: TOut

        Optional initial accumulator; falls back to the first element when omitted.

      Returns Iterable<TOut>

      A deferred iterable yielding each intermediate accumulator value in evaluation order.

      If seed is omitted and the source iterable is empty.

      const runningTotals = [..._scan([1, 2, 3], (prev, curr) => prev + curr, 0)];
      console.log(runningTotals); // [1, 3, 6]
    • Produces the intermediate accumulator values of a reduction over the source iterable.

      Type Parameters

      • T

        Element type produced by the source iterable.

      • _

      Parameters

      • src: Iterable<T>

        Source iterable providing values for the running aggregation.

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

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

      Returns Iterable<T>

      A deferred iterable yielding each intermediate accumulator value in evaluation order.

      If seed is omitted and the source iterable is empty.

      const runningTotals = [..._scan([1, 2, 3], (prev, curr) => prev + curr, 0)];
      console.log(runningTotals); // [1, 3, 6]