« get me outta code hell

add music commentary from pastebin + tumblrs - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/upd8-util.js
diff options
context:
space:
mode:
authorFlorrie <towerofnix@gmail.com>2019-11-17 00:27:49 -0400
committerFlorrie <towerofnix@gmail.com>2019-11-17 00:27:49 -0400
commitadd3806e515d6537e448fbb63ce2e817c1ee118c (patch)
tree61f1dc69a3d19e6eb9701373d9607ec425d5e999 /upd8-util.js
parentc765eda6fb33ff7449d3ce6f958a1210ef8b25df (diff)
add music commentary from pastebin + tumblrs
https://pastebin.com/gqpHsKkE
Diffstat (limited to 'upd8-util.js')
-rw-r--r--upd8-util.js14
1 files changed, 14 insertions, 0 deletions
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;
+    })));
+};