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