An open API service indexing awesome lists of open source software.

https://github.com/karmaniverous/async-find

Test values against a cascade of async functions to find the first one that passes all of them.
https://github.com/karmaniverous/async-find

async find

Last synced: 3 months ago
JSON representation

Test values against a cascade of async functions to find the first one that passes all of them.

Awesome Lists containing this project

README

          

# async-find

To install:

```bash
npm install @karmaniverous/async-find
```

To import:

```js
import { asyncFind } from '@karmaniverous/async-find`;
```

See
[tests](https://github.com/karmaniverous/async-find/blob/main/lib/asyncFind/asyncFind.test.js)
for examples of usage!

# API Documentation

## Functions



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.



## Typedefs



Predicate*


async predicate function callback



## 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>](#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](https://github.com/karmaniverous)!