« get me outta code hell

initial staging commit (data/media pruned) - 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:
author(quasar) nebula <towerofnix@gmail.com>2021-01-25 17:27:05 -0400
committer(quasar) nebula <towerofnix@gmail.com>2021-02-01 12:25:20 -0400
commit2b6e7d3d9950aad31536d63a835869502a70af46 (patch)
tree69e3dce33bea5c424251072d8088b7e3c11e8fb6 /upd8-util.js
parent1f50ae6aa6c71ae11d571ec4df012274e7717966 (diff)
initial staging commit (data/media pruned)
Diffstat (limited to 'upd8-util.js')
-rw-r--r--upd8-util.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/upd8-util.js b/upd8-util.js
index 28504eaf..a266efbd 100644
--- a/upd8-util.js
+++ b/upd8-util.js
@@ -28,6 +28,8 @@ module.exports.splitArray = function*(array, fn) {
 
 // This function's name is a joke. Jokes! Hahahahahahahaha. Funny.
 module.exports.joinNoOxford = function(array, plural = 'and') {
+    array = array.filter(Boolean);
+
     if (array.length === 0) {
         // ????????
         return '';
@@ -45,6 +47,10 @@ module.exports.joinNoOxford = function(array, plural = 'and') {
 };
 
 module.exports.progressPromiseAll = function (msg, array) {
+    if (!array.length) {
+        return Promise.resolve([]);
+    }
+
     let done = 0, total = array.length;
     process.stdout.write(`\r${msg} [0/${total}]`);
     const start = Date.now();
@@ -296,3 +302,5 @@ module.exports.parseOptions = parseOptions;
 module.exports.curry = f => x => (...args) => f(x, ...args);
 
 module.exports.mapInPlace = (array, fn) => array.splice(0, array.length, ...array.map(fn));
+
+module.exports.filterEmptyLines = string => string.split('\n').filter(line => line.trim()).join('\n');