@karmaniverous/async-find
v2.1.7
Published
Test values against a cascade of async functions to find the first one that passes all of them.
Downloads
1
Readme
async-find
To install:
npm install @karmaniverous/async-find
To import:
import { asyncFind } from '@karmaniverous/async-find`;
See tests for examples of usage!
API Documentation
Functions
Typedefs
asyncFind(values, predicates) ⇒ Array
Step through a array of input values. Pass each input value through an array of async predicate functions, passing the output of each predicate as the input of the next, until either the predicates are exhausted or one of them returns a falsy result.
Kind: global function
Returns: Array - An array containing the first input value that survived all
predicates, and its final predicate output.
| Param | Type | Description | | --- | --- | --- | | values | Array | array of values | | predicates | Array.<Predicate> | array of async predicate functions |
Predicate ⇒ *
async predicate function callback
Kind: global typedef
Returns: * - output
| Param | Type | Description | | --- | --- | --- | | [value] | * | value to be tested |
See more great templates and other tools on my GitHub Profile!