funq
A simple asynchronous function queue, executing either sequentially or in parallel.
Installation
$ npm install funq --save
...or:
$ yarn add funq
Usage
Create a new instance of Funq()
. Each object will have a push()
method, taking a callback as an argument
and sequential()
and parallel()
methods to kick the whole process off. The constructor function takes
a completion callback with an error value which will either contain an error object/string, etc.. or be null
if no errors were passed back, this is called once the whole chain of functions have finished.
If parallel()
is used, then all functions pushed to the instance will run immediately and the
completion callback will be called once the slowest function has finished, otherwise, using sequential()
everything will run in order and take as long as all the functions take to complete. Also you can
optionally pass a value back (i.e. done([value])
) which will complete the sequence early.
Example:
const Funq = const queue = { if err return console // an error was passed back and the sequence ended early // otherwise do stuff after sequence is fully completed} queue queue queue queue // or `.parallel()`
Browsers
Use browserify
or similar.