Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "utils/find/docs/types/index.d"

Index

Interfaces

Type aliases

Functions

Type aliases

Binary

Binary: (value: any, index: number) => boolean

Checks whether an element in a collection passes a test.

param

collection value

param

collection index

returns

boolean indicating whether an element in a collection passes a test

Type declaration

    • (value: any, index: number): boolean
    • Parameters

      • value: any
      • index: number

      Returns boolean

Callback

Callback: Nullary | Unary | Binary | Ternary

Checks whether an element in a collection passes a test.

param

collection value

param

collection index

param

input collection

returns

boolean indicating whether an element in a collection passes a test

Nullary

Nullary: () => boolean

Checks whether an element in a collection passes a test.

returns

boolean indicating whether an element in a collection passes a test

Type declaration

    • (): boolean
    • Returns boolean

Ternary

Ternary: (value: any, index: number, collection: Collection) => boolean

Checks whether an element in a collection passes a test.

param

collection value

param

collection index

param

input collection

returns

boolean indicating whether an element in a collection passes a test

Type declaration

    • (value: any, index: number, collection: Collection): boolean
    • Parameters

      Returns boolean

Unary

Unary: (value: any) => boolean

Checks whether an element in a collection passes a test.

param

collection value

returns

boolean indicating whether an element in a collection passes a test

Type declaration

    • (value: any): boolean
    • Parameters

      • value: any

      Returns boolean

Functions

Export assignment find

  • Finds elements in an array-like object that satisfy a test condition.

    Parameters

    • arr: Collection

      object from which elements will be tested

    • clbk: Callback

      function invoked for each array element. If the return value is truthy, the value is considered to have satisfied the test condition.

    Returns Array < any > | Array < [ number , any ] >

    array of indices, element values, or arrays of index-value pairs

    Example

    var data = [ 30, 20, 50, 60, 10 ];
    var vals = find( data, condition );
    // returns [ 0, 2, 3 ]
    
    function condition( val ) {
        return val > 20;
    }

    Example

    var data = [ 30, 20, 50, 60, 10 ];
    var vals = find( data, condition );
    // returns []
    
    function condition( val ) {
        return val > 1000;
    }
  • Finds elements in an array-like object that satisfy a test condition.

    Parameters

    • arr: Collection | string

      object from which elements will be tested

    • options: Options

      function options

    • clbk: Callback

      function invoked for each array element. If the return value is truthy, the value is considered to have satisfied the test condition.

    Returns Array < any > | Array < [ number , any ] >

    array of indices, element values, or arrays of index-value pairs

    Example

    var data = [ 30, 20, 50, 60, 10 ];
    var opts = {
        'k': 2,
        'returns': 'values'
    };
    var vals = find( data, opts, condition );
    // returns [ 30, 50 ]
    
    function condition( val ) {
        return val > 20;
    }

    Example

    var data = [ 30, 20, 50, 60, 10 ];
    var opts = {
        'k': -2,
        'returns': 'values'
    };
    var vals = find( data, opts, condition );
    // returns [ 60, 50 ]
    
    function condition( val ) {
        return val > 20;
    }

    Example

    var data = [ 30, 20, 50, 60, 10 ];
    var opts = {
        'k': -2,
        'returns': '*'
    };
    var vals = find( data, opts, condition );
    // returns [ [3, 60], [2, 50] ]
    
    function condition( val ) {
        return val > 20;
    }