« get me outta code hell

new Albums - by Date Added to Wiki listing - 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-04-10 22:28:17 -0300
committer(quasar) nebula <towerofnix@gmail.com>2021-04-10 22:28:17 -0300
commit0d0d38ce51ca02b7c3bd91317b5fa0bbff1f06de (patch)
treed78594d4b44bb806eccf7f2a3c4f8ec9707622d5 /upd8-util.js
parente99c48d128744a77c672cdf8f19dcf3cdc395b9b (diff)
new Albums - by Date Added to Wiki listing
Diffstat (limited to 'upd8-util.js')
-rw-r--r--upd8-util.js13
1 files changed, 12 insertions, 1 deletions
diff --git a/upd8-util.js b/upd8-util.js
index 6ff34199..abeed6c1 100644
--- a/upd8-util.js
+++ b/upd8-util.js
@@ -370,7 +370,18 @@ module.exports.chunkByConditions = function(array, conditions) {
 };
 
 module.exports.chunkByProperties = function(array, properties) {
-    return module.exports.chunkByConditions(array, properties.map(p => (a, b) => a[p] !== b[p] || a[p] != b[p]))
+    return module.exports.chunkByConditions(array, properties.map(p => (a, b) => {
+        if (a[p] instanceof Date && b[p] instanceof Date)
+            return +a[p] !== +b[p];
+
+        if (a[p] !== b[p]) return true;
+
+        // Not sure if this line is still necessary with the specific check for
+        // d8tes a8ove, 8ut, uh, keeping it anyway, just in case....?
+        if (a[p] != b[p]) return true;
+
+        return false;
+    }))
         .map(chunk => ({
             ...Object.fromEntries(properties.map(p => [p, chunk[0][p]])),
             chunk