Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "utils/do-until-each/docs/types/index.d"

Index

Type aliases

Binary

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

Function invoked for each collection element until a test condition is true.

param

collection value

param

collection index

Type declaration

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

      • value: any
      • index: number

      Returns void

BinaryPredicate

BinaryPredicate: (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

Function invoked for each collection element until a test condition is true.

param

collection value

param

collection index

param

input collection

Nullary

Nullary: () => void

Function invoked for each collection element until a test condition is true.

Type declaration

    • (): void
    • Returns void

NullaryPredicate

NullaryPredicate: () => 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

Predicate

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

Ternary

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

Function invoked for each collection element until a test condition is true.

param

collection value

param

collection index

param

input collection

Type declaration

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

      Returns void

TernaryPredicate

TernaryPredicate: (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) => void

Function invoked for each collection element until a test condition is true.

param

collection value

Type declaration

    • (value: any): void
    • Parameters

      • value: any

      Returns void

UnaryPredicate

UnaryPredicate: (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 doUntilEach

  • Until a test condition is true, invokes a function once for each element in a collection.

    Notes

    • The condition is evaluated after executing the function to invoke; thus, the provided function always executes at least once.

    • When invoked, both the predicate function and the function to apply are provided three arguments:

      • value: collection value
      • index: collection index
      • collection: the input collection
    • If provided an empty collection, the function invokes the provided function with the collection index set to undefined.

    Parameters

    • collection: Collection

      input collection

    • fcn: Callback

      function to invoke

    • predicate: Predicate

      function which indicates whether to stop iterating over a collection

    • Optional thisArg: any

      execution context for the applied function

    Returns Collection

    input collection

    Example

    function predicate( v, index, collection ) {
        return ( v !== v );
    }
    
    function log( v, index, collection ) {
        console.log( '%s: %d', index, v );
    }
    
    var arr = [ 1, 2, 3, 4, NaN, 5 ];
    
    doUntilEach( arr, log, predicate );