Skip to content

Instantly share code, notes, and snippets.

@bryanwb
Created Feb 25, 2010
Embed
What would you like to do?
function divide(a, b) { return function (callback, errback) {
// Use nextTick to prove that we're working asynchronously
process.nextTick(function () {
if (b === 0) {
errback(new Error("Cannot divide by 0"));
} else {
callback(a / b);
}
});
}}
divide(100, 10)(function (result) {
puts("the result is " + result);
}, function (error) {
throw error;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment