Skip to content

Instantly share code, notes, and snippets.

@otiai10
Last active July 6, 2017 07:09
Show Gist options
  • Save otiai10/a4e6824248da5d390154fc9f49965d75 to your computer and use it in GitHub Desktop.
Save otiai10/a4e6824248da5d390154fc9f49965d75 to your computer and use it in GitHub Desktop.
ほしいもの
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