« get me outta code hell

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:
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 6ff3419..abeed6c 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