transferum
    Preparing search index...

    Function createReducerOperator

    • Creates a ReducerOperator — an array reduce operator to a single value.

      Type Parameters

      • T

        — array element type

      Parameters

      • reducer: (acc: T, curr: T) => T

        — reduce function

      • OptionaldefaultValue: T

        — default value for an empty array

      Returns ReducerOperator<T>

      const op = createReducerOperator<number>((acc, curr) => acc + curr, 0);
      op.apply([1, 2, 3]); // 6
      op.apply([]); // 0