run-each
run-each
is a very small, flexible, parallel async iteration helper that has first-class support for Iterators
(unlike other libraries, which mostly break with iterators) and concurrency. It also has complete TypeScript header files for
comfortable integration.
npm i run-each --save
It is similar to each
, async-each
, each-async
, ... and many other.
const runEach =
There are several things that make this different:
- It returns an
Iterable
object instead of an Array. - It supports
Promises
in case you prefer to use async/await with your API's - It supports
concurrency
limits to limit the amount of commands executed at the same time.
Iterable results
Like in other libraries you can get the result, but unlike other libraries, its not
an Array, so you need to apply an Array.from
to it.
Note: This is more of an internal detail, but if the passed-in function doesn't have a second parameter, the data will not be collected.
Promise support
If you don't pass in a callback handler at the end, it will automatically return a Promise.
Concurrency
By passing a concurrency limit to the runner, it will limit the amount of parallel executions
License
MIT