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 --- src/data/composite/wiki-data/withDirectory.js | 41 ++++++++++++++++----------- 1 file changed, 24 insertions(+), 17 deletions(-) (limited to 'src/data/composite/wiki-data/withDirectory.js') diff --git a/src/data/composite/wiki-data/withDirectory.js b/src/data/composite/wiki-data/withDirectory.js index a3f4ceda..f3bedf2e 100644 --- a/src/data/composite/wiki-data/withDirectory.js +++ b/src/data/composite/wiki-data/withDirectory.js @@ -7,9 +7,9 @@ import {input, templateCompositeFrom} from '#composite'; import {isDirectory, isName} from '#validators'; -import {withResultOfAvailabilityCheck} from '#composite/control-flow'; +import {raiseOutputWithoutDependency} from '#composite/control-flow'; -import withDirectoryFromName from './helpers/withDirectoryFromName.js'; +import withSimpleDirectory from './helpers/withSimpleDirectory.js'; export default templateCompositeFrom({ annotation: `withDirectory`, @@ -26,30 +26,37 @@ export default templateCompositeFrom({ defaultDependency: 'name', acceptsNull: true, }), + + suffix: input({ + validate: isDirectory, + defaultValue: null, + }), }, outputs: ['#directory'], steps: () => [ - withResultOfAvailabilityCheck({ - from: input('directory'), + withSimpleDirectory({ + directory: input('directory'), + name: input('name'), + }), + + raiseOutputWithoutDependency({ + dependency: '#directory', + output: input.value({['#directory']: null}), }), { - dependencies: ['#availability', input('directory')], + dependencies: ['#directory', input('suffix')], compute: (continuation, { - ['#availability']: availability, - [input('directory')]: directory, - }) => - (availability - ? continuation.raiseOutput({ - ['#directory']: directory - }) - : continuation()), + ['#directory']: directory, + [input('suffix')]: suffix, + }) => continuation({ + ['#directory']: + (suffix + ? directory + '-' + suffix + : directory), + }), }, - - withDirectoryFromName({ - name: input('name'), - }), ], }); -- cgit 1.3.0-6-gf8a5