Created
June 8, 2012 23:05
-
-
Save darrenderidder/2898569 to your computer and use it in GitHub Desktop.
serialize some async functions in node 5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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