Skip to content

Instantly share code, notes, and snippets.

@darrenderidder
Created June 8, 2012 23:05
Show Gist options
  • Save darrenderidder/2898569 to your computer and use it in GitHub Desktop.
Save darrenderidder/2898569 to your computer and use it in GitHub Desktop.
serialize some async functions in node 5
// how we create the specialized callbacks
function createCallback(index) {
return function (err, result) {
var next = steps[index+1];
var cb = callbacks[index+1];
if (err) {
console.log('Error: ' + err.message);
} else if (result) {
console.log('Result: ' + JSON.stringify(result));
}
if (next) {
next(cb);
} else {
console.log('Finished!');
process.exit(0);
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment