Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "assert/tools/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 arrayfcn

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

    Notes

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

    Parameters

    Returns Function

    an array function

    Example

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