Created
August 3, 2016 02:36
-
-
Save Azerothian/8bf3d52d89f442cb5a04edc263d281d4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 waterfall(arr) { | |
return arr.reduce((promise, func) => { | |
return promise.then(func); | |
}, Promise.resolve()); | |
} | |
// | |
// function waterfall(arr) { | |
// log.info("have we hit yet"); | |
// if (arr.length === 0) { | |
// log.info("hit the ground"); | |
// return Promise.resolve(); | |
// } | |
// return Promise.resolve() | |
// .then(arr.pop()) | |
// .then(() => { | |
// log.info("falling"); | |
// return waterfall(arr); | |
// }, (err) => { | |
// log.info("water fall error occurred", err); | |
// if (err.stack) { | |
// log.info("waterfall error stack", err.stack); | |
// } | |
// return Promise.reject(err); | |
// }); | |
// } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment