Skip to content

Instantly share code, notes, and snippets.

@grawk
Created June 2, 2017 16:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grawk/9f878826dc51a873adcb05b1b00eb25e to your computer and use it in GitHub Desktop.
Save grawk/9f878826dc51a873adcb05b1b00eb25e to your computer and use it in GitHub Desktop.
nextTick
var queue = [];
for (var i = 0; i < 10; i++) {
queue.push(function () {
process.nextTick(function () {
console.log(Date.now());
(queue.length > 0) ? queue.shift()() : null;
});
});
}
queue.shift()();
console.log('after');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment