Last active
July 6, 2017 07:09
-
-
Save otiai10/a4e6824248da5d390154fc9f49965d75 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
const PP = require('progressive-promise'); | |
const p = new PP((resolve, reject, progress) => { | |
const total = 100; | |
let count = 0; | |
const intvl = setInterval(() => { | |
count += 1; | |
if (count > total) { | |
clearInterval(intvl); | |
return resolve(count); | |
} | |
progress(count); | |
}); | |
}); | |
p.progress(val => { | |
console.log("途中", val); | |
}).then(val => { | |
console.log("完了", val); | |
}).catch(err => { | |
console.log("失敗", err); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment