« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/util/wiki-data.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/wiki-data.js')
-rw-r--r--src/util/wiki-data.js16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/util/wiki-data.js b/src/util/wiki-data.js
index 97ffab7..b0b0b2e 100644
--- a/src/util/wiki-data.js
+++ b/src/util/wiki-data.js
@@ -2,6 +2,8 @@
 
 // Utility functions for interacting with wiki data.
 
+import {empty} from './sugar.js';
+
 // Generic value operations
 
 export function getKebabCase(name) {
@@ -16,9 +18,11 @@ export function getKebabCase(name) {
 }
 
 export function chunkByConditions(array, conditions) {
-  if (array.length === 0) {
+  if (empty(array)) {
     return [];
-  } else if (conditions.length === 0) {
+  }
+
+  if (empty(conditions)) {
     return [array];
   }
 
@@ -469,7 +473,7 @@ export function getNewAdditions(numAlbums, {wikiData}) {
     // Then cycle over that sorted array, adding one al8um from each to
     // the main array until we've run out or have met the target num8er
     // of al8ums.
-    while (groupArray.length) {
+    while (!empty(groupArray)) {
       let j = 0;
       while (j < groupArray.length) {
         const entry = groupArray[j];
@@ -485,10 +489,10 @@ export function getNewAdditions(numAlbums, {wikiData}) {
           break outerLoop;
         }
 
-        if (entry.length) {
-          j++;
-        } else {
+        if (empty(entry)) {
           groupArray.splice(j, 1);
+        } else {
+          j++;
         }
       }
     }