Created
September 22, 2016 01:41
-
-
Save tywong/1435eedc96b9508d42fbbb4e7e37544f 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
const Promise = require('bluebird'); | |
let array = [ | |
10, 10, 10, 10, 10, 10 | |
]; | |
return Promise.reduce(array, | |
(total, key, idx) => { | |
console.log(idx); | |
if(total == 20) | |
return Promise.reject(total); | |
else { | |
return Promise.resolve(total+key); | |
} | |
}, 0 | |
) | |
.then( x => console.log("then", x)) | |
.catch( x => console.log("catch", x)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment