Skip to content

Instantly share code, notes, and snippets.

@Eli-Goldberg
Last active March 29, 2017 13:58
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 Eli-Goldberg/2b549e1d1286ba211d1a281ad68f8c14 to your computer and use it in GitHub Desktop.
Save Eli-Goldberg/2b549e1d1286ba211d1a281ad68f8c14 to your computer and use it in GitHub Desktop.
Using async-waterfall to avoid callback hell
const waterfall = require('async-waterfall');
waterfall([
function(callback){
callback(null, 'one', 'two');
},
function(arg1, arg2, callback){
callback(null, 'three');
},
function(arg1, callback){
// arg1 now equals 'three'
callback(null, 'done');
}
], function (err, result) {
// result now equals 'done'
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment