Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "utils/while-each-right/docs/types/index.d"

Index

Type aliases

Binary

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

Function invoked for each collection element passing a test.

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 passing a test.

param

collection value

param

collection index

param

input collection

Nullary

Nullary: () => void

Function invoked for each collection element passing a test.

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 passing a test.

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 passing a test.

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 whileEachRight

  • While a test condition is true, invokes a function once for each element in a collection, iterating from right to left.

    Notes

    • 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
    • For dynamic array resizing, the only behavior made intentionally consistent with whileEach (iterating from left to right) is when elements are pushed onto the beginning (end) of an array. In other words, for whileEach(), [].push() behavior is consistent with whileEachRight() [].unshift() behavior.

    Parameters

    • collection: Collection

      input collection

    • predicate: Predicate

      function which indicates whether to continue iterating over a collection

    • fcn: Callback

      function to invoke

    • 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, NaN, 2, 3, 4, 5 ];
    
    whileEachRight( arr, predicate, log );