cheeky-async v1.0.0
cheeky-async
Some cheeky async versions of Array methods like
map,filterandreduce. With support for sequential and parallel processing.
Table of Contents
Usage
import {map} from "cheeky-async"
await map([1, 2, 3], async (value) => {
return value + (await getThingy())
})Install
This project uses node and npm.
$ npm install cheeky-async
$ # OR
$ yarn add cheeky-asyncAPI
Table of Contents
map
Invoke an async transform/mapping function on each item in an Array returning the resulting Array of transformed/mapped items. Async async transform/mapping function is invoked in parallel by default.
This is an async version of
Array.prototype.map().
Parameters
arrayArray The Array to map overmapperMapperFunction Async function, gets passed(value, index, array), returns the new value.configConfig Configuration
filter
Invoke an async predicate function on each item in an Array returning the resulting Array with all items passing the condition of the predicate function. Async async predicate function is invoked in parallel by default.
This is an async version of
Array.prototype.filter().
Parameters
arrayArray The Array to map overmapperPredicateFunction Async function, gets passed(value, index, array), returns the new value.configConfig Configuration
Returns Promise resulting mapped/transformed values.
every
Invoke an async predicate function on each item in an Array returning true/false depending on all items passing the condition of the predicate function. Async async predicate function is invoked in parallel by default.
This is an async version of
Array.prototype.every().
Parameters
arrayArray The Array to map overmapperPredicateFunction Async function, gets passed(value, index, array), returns the new value.configConfig Configuration
Returns Promise<Boolean> resulting mapped/transformed values.
some
Invoke an async predicate function on each item in an Array returning true/false depending on any items passing the condition of the predicate function. Async async predicate function is invoked in parallel by default.
This is an async version of
Array.prototype.some().
Parameters
arrayArray The Array to map overmapperPredicateFunction Async function, gets passed(value, index, array), returns the new value.configConfig Configuration
Returns Promise<Boolean> resulting mapped/transformed values.
reduce
Invoke an async reducer function on each item in an Array returning the resulting value. Async async reducer function is invoked in sequence by default.
This is an async version of
Array.prototype.reduce().
Parameters
arrayArray The Array to reduce.reducerreducerFunction Async function, gets passed(accumulator, value, index, array), returns the new accumulator.configConfig Configuration
Returns Promise resulting value.
Contribute
- Fork it and create your feature branch:
git checkout -b my-new-feature - Commit your changes:
git commit -am "Add some feature" - Push to the branch:
git push origin my-new-feature - Submit a pull request
License
MIT
5 years ago