From add3806e515d6537e448fbb63ce2e817c1ee118c Mon Sep 17 00:00:00 2001 From: Florrie Date: Sun, 17 Nov 2019 00:27:49 -0400 Subject: add music commentary from pastebin + tumblrs https://pastebin.com/gqpHsKkE --- upd8-util.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'upd8-util.js') diff --git a/upd8-util.js b/upd8-util.js index b36fbc9..b94ffe3 100644 --- a/upd8-util.js +++ b/upd8-util.js @@ -43,3 +43,17 @@ module.exports.joinNoOxford = function(array, plural = 'and') { return `${array.slice(0, -1).join(', ')} ${plural} ${array[array.length - 1]}`; }; + +module.exports.progressPromiseAll = function (msg, array) { + let done = 0, total = array.length; + process.stdout.write(`\r${msg} [0/${total}]`); + return Promise.all(array.map(promise => promise.then(val => { + done++; + if (done === total) { + process.stdout.write(`\r\x1b[2m${msg} [${done}/${total}] \x1b[0;32mDone!\x1b[0m \n`) + } else { + process.stdout.write(`\r${msg} [${done}/${total}]`); + } + return val; + }))); +}; -- cgit 1.3.0-6-gf8a5