abbado
Conductor for concurrent async control flow. Simple way to stop all concurrent task-running flows without aborting currently running tasks. Also it's a good way to pause all flows at the same time from one place of code.
Install
npm i abbado
Usage
const abbado = ;const _ = ;
methods:
stopped
- returnsfalse
if control flow is not stopped and stats object otherwise.stop
- manually stop control flow (if not stopped yet) and reset pause (if paused). Optional parameter is a custom stats object or string forstatus
field of stats object. Returns stats object.pause
- set flows on pause (only parameter - pause length in ms).resume
- alias forpause(0)
.wait
- waits for pause finish. Actually returns promise, that resolves after pause finished or immediately if there is no pause or if already stopped. If pause will be changed after waiting started, promise will wait for new pause length before resolve. Ifstop
orresume
will be called after waiting started, promise will resolve immediately.error
- reports error. Optional parameter is string tag, describing kind of error. Returns array of two numbers: number of all reported errors and number of errors with same tag (ornull
if no tag).paused
- feturnstrue
orfalse
whether control flow is paused or not.
options:
timeout
- time in milliseconds time in milliseconds, after which control flow will be stopped.count
- number limiting how many timesstopped
may returnfalse
.errorLimit
- number limiting how many errors may be reported byerror
method before control flow will be stopped.tagErrorLimit
- same aserrorLimit
but for any single tag.
example:
console; //false_;_ ; //{status: 'stopped manually'}
License
MIT