@szilanor/stream
    Preparing search index...

    Function scan

    • Returns an OperationFunction that yields the result of applying the reducer function to each element of the source.

      Type Parameters

      • T

        Type of items in the source.

      • O

        Type of items to yield.

      Parameters

      • reducerFunction: ReduceFunction<T, O>

        A function that reduces the source to a single value.

      • initialValue: ValueOrFactory<O>

        Initial value or factory function to use as the first argument to the reducer function.

      Returns OperationFunction<T, O>

      An OperationFunction that yields the result of applying the reducer function to each element of the source.

      const result = scan<number, number>((prev, curr) => prev + curr, 0)([1, 2, 3]);
      console.log([...result]); // [1, 3, 6]