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.
- Host: GitHub
- URL: https://github.com/karmaniverous/async-find
- Owner: karmaniverous
- Created: 2022-07-14T04:55:13.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-08-12T05:57:13.000Z (over 1 year ago)
- Last Synced: 2025-09-13T10:38:48.148Z (4 months ago)
- Topics: async, find
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/@karmaniverous/async-find
- Size: 2.14 MB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
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)!