Skip to content

Instantly share code, notes, and snippets.

@bcoe
Created May 11, 2014 20:08
Show Gist options
  • Select an option

  • Save bcoe/9c000455b1e1f04a0c72 to your computer and use it in GitHub Desktop.

Select an option

Save bcoe/9c000455b1e1f04a0c72 to your computer and use it in GitHub Desktop.
un-nested-callbacks.js
function a(b, cb) {
d(null, b * 2, cb);
}
function d(err, c, cb) {
if (err) cb(err);
else f(null, c * 2, cb);
}
function f(err, e, cb) {
if (err) cb(err);
else cb(null, e * 2);
}
a(3, function(err, result) {
console.log(result);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment