From 163c541f4b8244f3c2fd8568ab3ef5cc4ed114a2 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sun, 3 Nov 2024 09:59:31 -0400 Subject: data: Track.suffixDirectory, Album.directorySuffix --- .../wiki-data/helpers/withSimpleDirectory.js | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/data/composite/wiki-data/helpers/withSimpleDirectory.js (limited to 'src/data/composite/wiki-data/helpers') diff --git a/src/data/composite/wiki-data/helpers/withSimpleDirectory.js b/src/data/composite/wiki-data/helpers/withSimpleDirectory.js new file mode 100644 index 00000000..08ca3bfc --- /dev/null +++ b/src/data/composite/wiki-data/helpers/withSimpleDirectory.js @@ -0,0 +1,52 @@ +// A "simple" directory, based only on the already-provided directory, if +// available, or the provided name. + +import {input, templateCompositeFrom} from '#composite'; + +import {isDirectory, isName} from '#validators'; + +import {withResultOfAvailabilityCheck} from '#composite/control-flow'; + +import withDirectoryFromName from './withDirectoryFromName.js'; + +export default templateCompositeFrom({ + annotation: `withSimpleDirectory`, + + inputs: { + directory: input({ + validate: isDirectory, + defaultDependency: 'directory', + acceptsNull: true, + }), + + name: input({ + validate: isName, + acceptsNull: true, + }), + }, + + outputs: ['#directory'], + + steps: () => [ + withResultOfAvailabilityCheck({ + from: input('directory'), + }), + + { + dependencies: ['#availability', input('directory')], + compute: (continuation, { + ['#availability']: availability, + [input('directory')]: directory, + }) => + (availability + ? continuation.raiseOutput({ + ['#directory']: directory + }) + : continuation()), + }, + + withDirectoryFromName({ + name: input('name'), + }), + ], +}); -- cgit 1.3.0-6-gf8a5