The fastest async handler in node.js
Because asynchronous calls suck out your brain without a proper async handler. This one is just 4 lines yet it solves a huge issue.
npm install nextjs
var next = new Next(2, finish)
next()as many times as you specified in the
count. In this example it is 2.
nextwas called 2 times, the
finishfunction will be called.
// Includevar Next = require'nextjs';// CREATE a Next Instancevar next = 2 finish;// Log Startconsole.log'start';// Will happen after 5 seconds passedsetTimeout console.log'A'; next; 5000;// Will happen after 2 seconds passedsetTimeout console.log'B'; next; 2000;// Will happen in the end after 5 seconds passedconsole.log'finished';// output result// 0 second => start// 2 second => B// 5 second => A// 5 second => finished