« get me outta code hell

withSuffixDirectoryFromAlbum.js « track « things « composite « data « src - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/composite/things/track/withSuffixDirectoryFromAlbum.js
blob: 7159a3f4696715e49752d43a8b86ad3c94f3fbf2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import {input, templateCompositeFrom} from '#composite';

import {withResultOfAvailabilityCheck} from '#composite/control-flow';

import withPropertyFromAlbum from './withPropertyFromAlbum.js';

export default templateCompositeFrom({
  annotation: `withSuffixDirectoryFromAlbum`,

  inputs: {
    flagValue: input({
      defaultDependency: 'suffixDirectoryFromAlbum',
      acceptsNull: true,
    }),
  },

  outputs: ['#suffixDirectoryFromAlbum'],

  steps: () => [
    withResultOfAvailabilityCheck({
      from: 'suffixDirectoryFromAlbum',
    }),

    {
      dependencies: [
        '#availability',
        'suffixDirectoryFromAlbum'
      ],

      compute: (continuation, {
        ['#availability']: availability,
        ['suffixDirectoryFromAlbum']: flagValue,
      }) =>
        (availability
          ? continuation.raiseOutput({['#suffixDirectoryFromAlbum']: flagValue})
          : continuation()),
    },

    withPropertyFromAlbum({
      property: input.value('suffixTrackDirectories'),
    }),

    {
      dependencies: ['#album.suffixTrackDirectories'],
      compute: (continuation, {
        ['#album.suffixTrackDirectories']: suffixTrackDirectories,
      }) => continuation({
        ['#suffixDirectoryFromAlbum']:
          suffixTrackDirectories,
      }),
    },
  ],
});