« get me outta code hell

fix unique artists not being shown in track list - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/util/sugar.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2022-03-07 00:31:48 -0400
committer(quasar) nebula <qznebula@protonmail.com>2022-03-07 00:31:48 -0400
commite1141ea9d7554ac03bd1831bf882a45706e0b46b (patch)
tree5c919f3179df72b98e3db7424065d969dfd3dcbb /src/util/sugar.js
parentc72a05cf795b4bab51c2e0cef4eff0bc210fe3e8 (diff)
fix unique artists not being shown in track list
Diffstat (limited to 'src/util/sugar.js')
-rw-r--r--src/util/sugar.js5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/util/sugar.js b/src/util/sugar.js
index c8f1706..7a13227 100644
--- a/src/util/sugar.js
+++ b/src/util/sugar.js
@@ -32,6 +32,11 @@ export const filterEmptyLines = string => string.split('\n').filter(line => line
 
 export const unique = arr => Array.from(new Set(arr));
 
+export const compareArrays = (arr1, arr2, {checkOrder = true} = {}) => (
+    arr1.length === arr2.length && (checkOrder
+        ? (arr1.every((x, i) => arr2[i] === x))
+        : (arr1.every(x => arr2.includes(x)))));
+
 // Stolen from jq! Which pro8a8ly stole the concept from other places. Nice.
 export const withEntries = (obj, fn) => Object.fromEntries(fn(Object.entries(obj)));