« get me outta code hell

data: withResolvedReferenceList: handle undefined matches - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-09-08 11:29:53 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-09-08 11:29:53 -0300
commit3ebe98d51d94a3e5277d65b2a4d2b5b433449214 (patch)
tree451c57ca48f321b740100433dea6702971f1ee60
parentee46a4f78f1bfc8348834fbd3349849148f178a8 (diff)
data: withResolvedReferenceList: handle undefined matches
-rw-r--r--src/data/things/thing.js5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/data/things/thing.js b/src/data/things/thing.js
index 91ad96a..79d8ae0 100644
--- a/src/data/things/thing.js
+++ b/src/data/things/thing.js
@@ -491,19 +491,20 @@ export function withResolvedReferenceList({
         let matches =
           list.map(ref => findFunction(ref, data, {mode: 'quiet'}));
 
-        if (!matches.includes(null)) {
+        if (matches.every(match => match)) {
           return continuation.raise({matches});
         }
 
         switch (notFoundMode) {
           case 'filter':
-            matches = matches.filter(value => value !== null);
+            matches = matches.filter(match => match);
             return continuation.raise({matches});
 
           case 'exit':
             return continuation.exit([]);
 
           case 'null':
+            matches = matches.map(match => match ?? null);
             return continuation.raise({matches});
         }
       },