Next
Because asynchronous calls suck out your brain without a proper async handler. This one is just 4 lines yet it solves a huge issue.
Install
npm install nextjs
How it works?
- Create a
Next Instance
: var next = new Next(2, finish)
- Then you call
next()
as many times as you specified in the count
. In this example it is 2. - After
next
was called 2 times, the finish
function will be called.
Example
var Next = require('nextjs');
var next = new Next(2, finish);
console.log('start');
setTimeout(function(){ console.log('A'); next(); }, 5000);
setTimeout(function(){ console.log('B'); next(); }, 2000);
function finish(){ console.log('finished'); }
Next parameters
- count: the number of times you will have to call the
next()
instance. required
integer
- finish: finishing callback
required
function
Key features
- It's just 4 lines -
0.16kb
- Easy to use
- Its part of
dietjs