Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "utils/map-reduce-right/docs/types/index.d"

Index

Type aliases

ArrayMapper

ArrayMapper<T, U>: Nullary<U> | Unary<T, U> | Binary<T, U> | ArrayTernary<T, U>

Callback invoked for each array element.

param

array element

param

element index

param

array

returns

result

Type parameters

  • T

  • U

ArrayQuaternaryReducer

ArrayQuaternaryReducer<U, V, T, W>: (this: W, accumulator: V, value: U, index: number, arr: Collection<T>) => V

Function applied against an accumulator.

param

accumulated value

param

array element

param

element index

param

array

returns

accumulator value

Type parameters

  • U

  • V

  • T

  • W

Type declaration

    • (this: W, accumulator: V, value: U, index: number, arr: Collection<T>): V
    • Parameters

      • this: W
      • accumulator: V
      • value: U
      • index: number
      • arr: Collection<T>

      Returns V

ArrayReducer

ArrayReducer<U, V, T, W>: NullaryReducer<V, W> | UnaryReducer<V, W> | BinaryReducer<U, V, W> | TernaryReducer<U, V, W> | ArrayQuaternaryReducer<U, V, T, W>

Function applied against an accumulator.

param

accumulated value

param

array element

param

element index

param

array

returns

accumulator value

Type parameters

  • U

  • V

  • T

  • W

ArrayTernary

ArrayTernary<T, U>: (value: T, index: number, arr: Collection<T>) => U

Callback invoked for each array element.

param

array element

param

element index

param

array

returns

result

Type parameters

  • T

  • U

Type declaration

    • (value: T, index: number, arr: Collection<T>): U
    • Parameters

      Returns U

Binary

Binary<T, U>: (value: T, index: number) => U

Callback invoked for each array element.

param

array element

param

element index

returns

result

Type parameters

  • T

  • U

Type declaration

    • (value: T, index: number): U
    • Parameters

      • value: T
      • index: number

      Returns U

BinaryReducer

BinaryReducer<U, V, W>: (this: W, accumulator: V, value: U) => V

Function applied against an accumulator.

param

accumulated value

param

array element

returns

accumulator value

Type parameters

  • U

  • V

  • W

Type declaration

    • (this: W, accumulator: V, value: U): V
    • Parameters

      • this: W
      • accumulator: V
      • value: U

      Returns V

Mapper

Mapper<T, U>: Nullary<U> | Unary<T, U> | Binary<T, U> | Ternary<T, U>

Callback invoked for each array element.

param

array element

param

element index

param

array

returns

result

Type parameters

  • T

  • U

Nullary

Nullary<U>: () => U

Callback invoked for each array element.

returns

result

Type parameters

  • U

Type declaration

    • (): U
    • Returns U

NullaryReducer

NullaryReducer<V, W>: (this: W) => V

Function applied against an accumulator.

returns

accumulator value

Type parameters

  • V

  • W

Type declaration

    • (this: W): V
    • Parameters

      • this: W

      Returns V

QuaternaryReducer

QuaternaryReducer<U, V, T, W>: (this: W, accumulator: V, value: U, index: number, arr: typedndarray<T>) => V

Function applied against an accumulator.

param

accumulated value

param

array element

param

element index

param

array

returns

accumulator value

Type parameters

  • U

  • V

  • T

  • W

Type declaration

    • (this: W, accumulator: V, value: U, index: number, arr: typedndarray<T>): V
    • Parameters

      • this: W
      • accumulator: V
      • value: U
      • index: number
      • arr: typedndarray<T>

      Returns V

Reducer

Reducer<U, V, T, W>: NullaryReducer<V, W> | UnaryReducer<V, W> | BinaryReducer<U, V, W> | TernaryReducer<U, V, W> | QuaternaryReducer<U, V, T, W>

Function applied against an accumulator.

param

accumulated value

param

array element

param

element index

param

array

returns

accumulator value

Type parameters

  • U

  • V

  • T

  • W

Ternary

Ternary<T, U>: (value: T, index: number, arr: typedndarray<T>) => U

Callback invoked for each array element.

param

array element

param

element index

param

array

returns

result

Type parameters

  • T

  • U

Type declaration

TernaryReducer

TernaryReducer<U, V, W>: (this: W, accumulator: V, value: U, index: number) => V

Function applied against an accumulator.

param

accumulated value

param

array element

param

element index

returns

accumulator value

Type parameters

  • U

  • V

  • W

Type declaration

    • (this: W, accumulator: V, value: U, index: number): V
    • Parameters

      • this: W
      • accumulator: V
      • value: U
      • index: number

      Returns V

Unary

Unary<T, U>: (value: T) => U

Callback invoked for each array element.

param

array element

returns

result

Type parameters

  • T

  • U

Type declaration

    • (value: T): U
    • Parameters

      • value: T

      Returns U

UnaryReducer

UnaryReducer<V, W>: (this: W, accumulator: V) => V

Function applied against an accumulator.

param

accumulated value

returns

accumulator value

Type parameters

  • V

  • W

Type declaration

    • (this: W, accumulator: V): V
    • Parameters

      • this: W
      • accumulator: V

      Returns V

Functions

Export assignment mapReduceRight

  • Performs a map-reduce operation for each element in an array while iterating from right to left and returns the accumulated result.

    Notes

    • The mapping function is provided four arguments:

      • value: array element.
      • index: element index.
      • arr: input array.
    • The reducing function is provided four arguments:

      • accumulator: accumulated value.
      • value: result after applying a mapping function to the current array element.
      • index: element index.
      • arr: input array.
    • If provided an empty array, the function returns the initial value.

    Type parameters

    • T

    • U

    • V

    • W

    Parameters

    • arr: typedndarray<T>

      input array

    • initial: V

      initial value

    • mapper: Mapper<T, U>

      mapping function

    • reducer: Reducer<U, V, T, W>

      reducing function

    • Optional thisArg: ThisParameterType<Reducer<U, V, T, W>>

      reducing function execution context

    Returns V

    accumulated result

    Example

    var naryFunction = require( '@stdlib/utils/nary-function' );
    var abs = require( '@stdlib/math/base/special/abs' );
    var add = require( '@stdlib/math/base/ops/add' );
    var array = require( '@stdlib/ndarray/array' );
    
    var opts = {
        'dtype': 'generic'
    };
    var arr = array( [ [ -1, -2, -3 ], [ -4, -5, -6 ] ], opts );
    
    var out = mapReduceRight( arr, 0, naryFunction( abs, 2 ), naryFunction( add, 2 ) );
    // returns 21
  • Performs a map-reduce operation for each element in an array while iterating from right to left and returns the accumulated result.

    Notes

    • The mapping function is provided four arguments:

      • value: array element.
      • index: element index.
      • arr: input array.
    • The reducing function is provided four arguments:

      • accumulator: accumulated value.
      • value: result after applying a mapping function to the current array element.
      • index: element index.
      • arr: input array.
    • If provided an empty array, the function returns the initial value.

    Type parameters

    • T

    • U

    • V

    • W

    Parameters

    • arr: Collection<T>

      input array

    • initial: V

      initial value

    • mapper: ArrayMapper<T, U>

      mapping function

    • reducer: ArrayReducer<U, V, T, W>

      reducing function

    • Optional thisArg: ThisParameterType<ArrayReducer<U, V, T, W>>

      reducing function execution context

    Returns V

    accumulated result

    Example

    function square( value ) {
        return value * value;
    }
    
    function sum( acc, value ) {
        return acc + value;
    }
    
    var arr = [ 1, 2, 3, 4 ];
    
    var out = mapReduceRight( arr, 0, square, sum );
    // returns 30