Package Exports
- nextjs
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (nextjs) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
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 nextjsHow it works?
- Create a
Next Instance:var next = new Next(2, finish) - Then you call
next()as many times as you specified in thecount. In this example it is 2. - After
nextwas called 2 times, thefinishfunction will be called.
Example
// Include
var Next = require('nextjs');
// CREATE a Next Instance
var next = new Next(2, finish);
// Log Start
console.log('start');
// Will happen after 5 seconds passed
setTimeout(function(){ console.log('A'); next(); }, 5000);
// Will happen after 2 seconds passed
setTimeout(function(){ console.log('B'); next(); }, 2000);
// Will happen in the end after 5 seconds passed
function finish(){ console.log('finished'); }
// output result
// 0 second => start
// 2 second => B
// 5 second => A
// 5 second => finishedNext parameters
- count: the number of times you will have to call the
next()instance.requiredinteger - finish: finishing callback
requiredfunction
Key features
- It's just 4 lines -
0.16kb - Easy to use
- Its part of
dietjs