Options
All
  • Public
  • Public/Protected
  • All
Menu

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

Index

Type aliases

Functions

Type aliases

Fcn

Fcn: Nullary | Unary

Invoked function.

param

invocation index

returns

result

Nullary

Nullary: () => any

Invoked function.

returns

result

Type declaration

    • (): any
    • Returns any

Unary

Unary: (i: number) => any

Invoked function.

param

invocation index

returns

result

Type declaration

    • (i: number): any
    • Parameters

      • i: number

      Returns any

Functions

Export assignment mapFun

  • mapFun(fcn: Fcn, n: number, thisArg?: any): Array<any>
  • Invokes a function n times and returns an array of accumulated function return values.

    Notes

    • The invoked function is provided a single argument: the invocation index (zero-based).
    throws

    second argument must be a nonnegative integer

    Parameters

    • fcn: Fcn

      function to invoke

    • n: number

      number of function invocations

    • Optional thisArg: any

      execution context

    Returns Array < any >

    accumulated results

    Example

    function fcn( i ) {
        return i;
    }
    
    var arr = mapFun( fcn, 5 );
    // returns [ 0, 1, 2, 3, 4 ]