« 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/things/contribution/thingPropertyMatches.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/data/composite/things/contribution/thingPropertyMatches.js')
-rw-r--r--src/data/composite/things/contribution/thingPropertyMatches.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/data/composite/things/contribution/thingPropertyMatches.js b/src/data/composite/things/contribution/thingPropertyMatches.js
new file mode 100644
index 00000000..4a37f2cf
--- /dev/null
+++ b/src/data/composite/things/contribution/thingPropertyMatches.js
@@ -0,0 +1,33 @@
+import {input, templateCompositeFrom} from '#composite';
+
+import {exitWithoutDependency} from '#composite/control-flow';
+
+export default templateCompositeFrom({
+  annotation: `thingPropertyMatches`,
+
+  compose: false,
+
+  inputs: {
+    value: input({type: 'string'}),
+  },
+
+  steps: () => [
+    exitWithoutDependency({
+      dependency: 'thingProperty',
+      value: input.value(false),
+    }),
+
+    {
+      dependencies: [
+        'thingProperty',
+        input('value'),
+      ],
+
+      compute: ({
+        ['thingProperty']: thingProperty,
+        [input('value')]: value,
+      }) =>
+        thingProperty === value,
+    },
+  ],
+});