« get me outta code hell

data: Artwork, constitutibleArtwork, etc - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/composite/things/artwork/withDate.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2025-03-31 15:04:20 -0300
committer(quasar) nebula <qznebula@protonmail.com>2025-04-10 16:02:35 -0300
commite8964d7a9f9dc787d4d84c0554d22149bb2daa0c (patch)
tree460944e7a5417ee8a998e37d7cbd05364398fd4f /src/data/composite/things/artwork/withDate.js
parent964273f8cb26c6d9df8ec827126167dc5b58ae27 (diff)
data: Artwork, constitutibleArtwork, etc
Not used in content yet.
Diffstat (limited to 'src/data/composite/things/artwork/withDate.js')
-rw-r--r--src/data/composite/things/artwork/withDate.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/data/composite/things/artwork/withDate.js b/src/data/composite/things/artwork/withDate.js
new file mode 100644
index 00000000..08f1427c
--- /dev/null
+++ b/src/data/composite/things/artwork/withDate.js
@@ -0,0 +1,35 @@
+import {input, templateCompositeFrom} from '#composite';
+
+import {withPropertyFromObject} from '#composite/data';
+
+export default templateCompositeFrom({
+  annotation: `withDate`,
+
+  inputs: {
+    from: input({
+      defaultDependency: 'date',
+      acceptsNull: true,
+    }),
+  },
+
+  outputs: ['#date'],
+
+  steps: () => [
+    {
+      dependencies: [input('from')],
+      compute: (continuation, {
+        [input('from')]: date,
+      }) =>
+        (date
+          ? continuation.raiseOutput({'#date': date})
+          : continuation()),
+    },
+
+    withPropertyFromObject({
+      object: 'thing',
+      property: 'dateFromThingProperty',
+    }).outputs({
+      ['#value']: '#date',
+    }),
+  ],
+})