From 2b6e7d3d9950aad31536d63a835869502a70af46 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Mon, 25 Jan 2021 17:27:05 -0400 Subject: initial staging commit (data/media pruned) --- upd8-util.js | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'upd8-util.js') diff --git a/upd8-util.js b/upd8-util.js index 28504ea..a266efb 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'); -- cgit 1.3.0-6-gf8a5