Skip to content

Instantly share code, notes, and snippets.

@kersny
Forked from amaltson/async.js
Created June 1, 2011 01:47
Show Gist options
  • Select an option

  • Save kersny/1001641 to your computer and use it in GitHub Desktop.

Select an option

Save kersny/1001641 to your computer and use it in GitHub Desktop.
Trying to figure out async in node
function testWithCallback(callback) {
process.nextTick(function() {
var result;
for (var i = 0; i < 1000000000000; i++ ) {
result += i;
}
callback(result);
});
}
testWithCallback(function(result) {
console.log(result);
});
console.log('This should happen right away');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment