sequence-stepper
The small lib for the asynchronous control of queue of functions. It can start an execution at any step in a queue till the end.
Installation
npm install --save sequence-stepper
Usage
class Stepper
Creation a stepper queue
; let stepper = stepnext++data data > 2 ? stepnextdata * 2 : step done ? console : null; console;
Callbacks arguments description
- step - a StepDescription instance. With that you can manipulate an execution.
- data - returned value of previous step
- done - flag of last step
Start an execution
stepperstartdata;
You can step back with the same code (backward step doesn't execute)
stepper;
Execute a step after stepDescriptor
steppernextdata steppersteps2;
Execution on some step in queue
let savedStepDescriptor; let stepper = {...} { //some behavior ... savedStepDescriptor = step; stepnext; } {...}; stepperstart//execute queue till the end savedStepDescriptornext//execute queue from saved step till the end;
insertBefore and insertAfter usage
let stepper = ... { step; step; stepnext; } ...;
or
let stepper = ...;stepper;
or
let savedStepDescriptor; let stepper = ... { savedStepDescriptor = step; stepnext; } ...; savedStepDescriptor;
Brief usage of Stepper
let stepper = console; stepperstart;
function sequence
Its help you to make a function thats launches a queue till the end. You can make it with this simple functional conveyors.
; let queue = ; let result = ;//result === 42
You can add an asynchronous behavior into a steps
let queue = ; ;//output 42 in console after 100ms
Notice
In outline Stepper and sequence has a similar behavior. If you don`t want to use insertAfter and insertBefore, you can restrict a sequence.