« get me outta code hell

data: withResolvedReference: remove notFoundMode input - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/composite/wiki-data/withResolvedReference.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-02-06 08:16:00 -0400
committer(quasar) nebula <qznebula@protonmail.com>2024-02-06 08:33:38 -0400
commit5eac956b82276d6342b4bbe6b10fac7b3a783bc4 (patch)
treeb2008e7fbd3ad1d338251483cda497339bf62e30 /src/data/composite/wiki-data/withResolvedReference.js
parent1b42f193421d5ca0376e006750b00b0e0b734607 (diff)
data: withResolvedReference: remove notFoundMode input
Diffstat (limited to 'src/data/composite/wiki-data/withResolvedReference.js')
-rw-r--r--src/data/composite/wiki-data/withResolvedReference.js32
1 files changed, 8 insertions, 24 deletions
diff --git a/src/data/composite/wiki-data/withResolvedReference.js b/src/data/composite/wiki-data/withResolvedReference.js
index 0fa5c55..ea71707 100644
--- a/src/data/composite/wiki-data/withResolvedReference.js
+++ b/src/data/composite/wiki-data/withResolvedReference.js
@@ -1,12 +1,10 @@
 // Resolves a reference by using the provided find function to match it
 // within the provided thingData dependency. This will early exit if the
-// data dependency is null, or, if notFoundMode is set to 'exit', if the find
-// function doesn't match anything for the reference. Otherwise, the data
-// object is provided on the output dependency; or null, if the reference
-// doesn't match anything or itself was null to begin with.
+// data dependency is null. Otherwise, the data object is provided on the
+// output dependency, or null, if the reference doesn't match anything or
+// itself was null to begin with.
 
 import {input, templateCompositeFrom} from '#composite';
-import {is} from '#validators';
 
 import {
   exitWithoutDependency,
@@ -23,11 +21,6 @@ export default templateCompositeFrom({
 
     data: inputWikiData({allowMixedTypes: false}),
     find: input({type: 'function'}),
-
-    notFoundMode: input({
-      validate: is('null', 'exit'),
-      defaultValue: 'null',
-    }),
   },
 
   outputs: ['#resolvedReference'],
@@ -49,25 +42,16 @@ export default templateCompositeFrom({
         input('ref'),
         input('data'),
         input('find'),
-        input('notFoundMode'),
       ],
 
-      compute(continuation, {
+      compute: (continuation, {
         [input('ref')]: ref,
         [input('data')]: data,
         [input('find')]: findFunction,
-        [input('notFoundMode')]: notFoundMode,
-      }) {
-        const match = findFunction(ref, data, {mode: 'quiet'});
-
-        if (match === null && notFoundMode === 'exit') {
-          return continuation.exit(null);
-        }
-
-        return continuation.raiseOutput({
-          ['#resolvedReference']: match ?? null,
-        });
-      },
+      }) => continuation({
+        ['#resolvedReference']:
+          findFunction(ref, data, {mode: 'quiet'}) ?? null,
+      }),
     },
   ],
 });