cheeky-async
v1.0.0
Published
Some cheeky async versions of Array methods like map, filter and reduce. With support for sequential and parallel processing.
Downloads
2
Readme
cheeky-async
Some cheeky async versions of Array methods like
map
,filter
andreduce
. 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-async
API
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
array
Array The Array to map overmapper
MapperFunction Async function, gets passed(value, index, array)
, returns the new value.config
Config 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
array
Array The Array to map overmapper
PredicateFunction Async function, gets passed(value, index, array)
, returns the new value.config
Config 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
array
Array The Array to map overmapper
PredicateFunction Async function, gets passed(value, index, array)
, returns the new value.config
Config 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
array
Array The Array to map overmapper
PredicateFunction Async function, gets passed(value, index, array)
, returns the new value.config
Config 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
array
Array The Array to reduce.reducer
reducerFunction Async function, gets passed(accumulator, value, index, array)
, returns the new accumulator.config
Config 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