| 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
 | // Gets the track's own date. This is either its dateFirstReleased property
// or, if unset, the album's date.
import {input, templateCompositeFrom} from '#composite';
import withPropertyFromAlbum from './withPropertyFromAlbum.js';
export default templateCompositeFrom({
  annotation: `withDate`,
  outputs: ['#date'],
  steps: () => [
    {
      dependencies: ['disableDate'],
      compute: (continuation, {disableDate}) =>
        (disableDate
          ? continuation.raiseOutput({'#date': null})
          : continuation()),
    },
    {
      dependencies: ['dateFirstReleased'],
      compute: (continuation, {dateFirstReleased}) =>
        (dateFirstReleased
          ? continuation.raiseOutput({'#date': dateFirstReleased})
          : continuation()),
    },
    withPropertyFromAlbum({
      property: input.value('date'),
    }),
    {
      dependencies: ['#album.date'],
      compute: (continuation, {['#album.date']: albumDate}) =>
        (albumDate
          ? continuation.raiseOutput({'#date': albumDate})
          : continuation.raiseOutput({'#date': null})),
    },
  ],
})
 |