« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/composite/wiki-data
diff options
context:
space:
mode:
Diffstat (limited to 'src/data/composite/wiki-data')
-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 0fa5c554..ea71707e 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,
+      }),
     },
   ],
 });