Options
All
  • Public
  • Public/Protected
  • All
Menu

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

Index

Type aliases

Binary

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

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

param

collection value

param

collection index

Type parameters

  • T

  • U

Type declaration

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

      • this: U
      • value: T
      • index: number

      Returns void

BinaryPredicate

BinaryPredicate<T>: (value: T, 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 parameters

  • T

Type declaration

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

      • value: T
      • index: number

      Returns boolean

Callback

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

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

param

collection value

param

collection index

param

input collection

Type parameters

  • T

  • U

Nullary

Nullary<U>: (this: U) => void

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

Type parameters

  • U

Type declaration

    • (this: U): void
    • Parameters

      • this: U

      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

Type parameters

  • T

Ternary

Ternary<T, U>: (this: U, value: T, index: number, collection: Collection<T>) => void

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

param

collection value

param

collection index

param

input collection

Type parameters

  • T

  • U

Type declaration

    • (this: U, value: T, index: number, collection: Collection<T>): void
    • Parameters

      • this: U
      • value: T
      • index: number
      • collection: Collection<T>

      Returns void

TernaryPredicate

TernaryPredicate<T>: (value: T, index: number, collection: Collection<T>) => 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 parameters

  • T

Type declaration

    • (value: T, index: number, collection: Collection<T>): boolean
    • Parameters

      • value: T
      • index: number
      • collection: Collection<T>

      Returns boolean

Unary

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

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

param

collection value

Type parameters

  • T

  • U

Type declaration

    • (this: U, value: T): void
    • Parameters

      • this: U
      • value: T

      Returns void

UnaryPredicate

UnaryPredicate<T>: (value: T) => 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 parameters

  • T

Type declaration

    • (value: T): boolean
    • Parameters

      • value: T

      Returns boolean

Functions

Export assignment doUntilEachRight

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

    Notes

    • For dynamic array resizing, the only behavior made intentionally consistent with doUntilEach (iterating from left to right) is when elements are pushed onto the beginning (end) of an array. In other words, for doUntilEach(), [].push() behavior is consistent with doUntilEachRight() [].unshift() behavior.

    • 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.

    Type parameters

    • T

    • U

    Parameters

    • collection: Collection<T>

      input collection

    • fcn: Callback<T, U>

      function to invoke

    • predicate: Predicate<T>

      function which indicates whether to stop iterating over a collection

    • Optional thisArg: ThisParameterType<Callback<T, U>>

      execution context for the applied function

    Returns Collection < T >

    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 ];
    
    doUntilEachRight( arr, log, predicate );