Skip to content

Instantly share code, notes, and snippets.

@bryanwb
Created February 25, 2010 12:27
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 bryanwb/314503 to your computer and use it in GitHub Desktop.
Save bryanwb/314503 to your computer and use it in GitHub Desktop.
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