Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "assert/tools/typed-array-function/docs/types/index.d"

Index

Type aliases

Functions

Type aliases

PredicateFunction

PredicateFunction: (elem: any) => boolean

Predicate function.

param

array element

returns

test result

Type declaration

    • (elem: any): boolean
    • Parameters

      • elem: any

      Returns boolean

Functions

Export assignment typedarrayfcn

  • Returns a function which tests if every element in a typed array passes a test condition.

    Notes

    • The predicate function should accept a single argument: a typed array element. If the element satisfies a test condition, the function should return true; otherwise, the function should return false.
    • Given an input typed array, the returned function returns true if all elements pass the test and false otherwise.
    • The returned function returns false if provided an empty typed array.
    • The returned function returns false is not provided a typed array.

    Parameters

    Returns Function

    a typed array function

    Example

    var isOdd = require( `@stdlib/assert/is-odd` );
    
    var arr1 = new Int32Array( [ 1, 3, 5, 7 ] );
    var arr2 = new Int32Array( [ 1, 3, 5, 8 ] );
    
    var validate = typedarrayfcn( isOdd );
    
    var bool = validate( arr1 );
    // returns true
    
    bool = validate( arr2 );
    // returns false