Options
All
  • Public
  • Public/Protected
  • All
Menu

Module object/reduce

Index

References

Type aliases

Functions

References

Renames and re-exports reduce

Type aliases

ReduceFunc<R, O>: (acc: R, value: O[keyof O], key: keyof O & string, obj: O) => R

Type parameters

  • R

  • O: Record<any, any>

Type declaration

    • (acc: R, value: O[keyof O], key: keyof O & string, obj: O): R
    • Parameters

      • acc: R
      • value: O[keyof O]
      • key: keyof O & string
      • obj: O

      Returns R

Functions

  • reduce<R, O>(fn: ReduceFunc<R, O>, acc: R, obj: O): R
  • reduce<R>(fn: ReduceFunc<R, any>, acc: R): (obj: any) => R
  • reduce(fn: ReduceFunc<any, any>): { <R>(acc: R, obj: any): R; <R>(acc: R): (obj: any) => R }
  • Returns a single item by iterating through the obj, successively calling the iterable function and passing it an accumulator value, current value and current key from the obj, and then passing the result to the next call.

    example
     var obj = { a: 1, b: 2, c: 3};
    var plus = (a, b) => a + b;

    reduce(plus, 10, obj); //=> 16

    Type parameters

    • R

    • O: Record<any, any>

    Parameters

    • fn: ReduceFunc<R, O>

      The iterable function. Receives three argument, accumulator, value, key.

    • acc: R

      The accumulator value.

    • obj: O

      The object to iterate over.

    Returns R

    The final, accumulated value.

  • Returns a single item by iterating through the obj, successively calling the iterable function and passing it an accumulator value, current value and current key from the obj, and then passing the result to the next call.

    example
     var obj = { a: 1, b: 2, c: 3};
    var plus = (a, b) => a + b;

    reduce(plus, 10, obj); //=> 16

    Type parameters

    • R

    Parameters

    • fn: ReduceFunc<R, any>

      The iterable function. Receives three argument, accumulator, value, key.

    • acc: R

      The accumulator value.

    Returns (obj: any) => R

    The final, accumulated value.

      • (obj: any): R
      • Parameters

        • obj: any

        Returns R

  • Returns a single item by iterating through the obj, successively calling the iterable function and passing it an accumulator value, current value and current key from the obj, and then passing the result to the next call.

    example
     var obj = { a: 1, b: 2, c: 3};
    var plus = (a, b) => a + b;

    reduce(plus, 10, obj); //=> 16

    Parameters

    • fn: ReduceFunc<any, any>

      The iterable function. Receives three argument, accumulator, value, key.

    Returns { <R>(acc: R, obj: any): R; <R>(acc: R): (obj: any) => R }

    The final, accumulated value.

      • <R>(acc: R, obj: any): R
      • <R>(acc: R): (obj: any) => R
      • Type parameters

        • R

        Parameters

        • acc: R
        • obj: any

        Returns R

      • Type parameters

        • R

        Parameters

        • acc: R

        Returns (obj: any) => R

          • (obj: any): R
          • Parameters

            • obj: any

            Returns R

Generated using TypeDoc