diff options
Diffstat (limited to 'src/data/composite/things')
-rw-r--r-- | src/data/composite/things/flash/withFlashAct.js | 48 | ||||
-rw-r--r-- | src/data/composite/things/track/withAlbum.js | 48 |
2 files changed, 12 insertions, 84 deletions
diff --git a/src/data/composite/things/flash/withFlashAct.js b/src/data/composite/things/flash/withFlashAct.js index 2c985fe0..652b8bfb 100644 --- a/src/data/composite/things/flash/withFlashAct.js +++ b/src/data/composite/things/flash/withFlashAct.js @@ -1,15 +1,10 @@ // Gets the flash's act. This will early exit if flashActData is missing. // If there's no flash whose list of flashes includes this flash, the output // dependency will be null. -// -// This step models with Flash.withAlbum. import {input, templateCompositeFrom} from '#composite'; -import {is} from '#validators'; -import {exitWithoutDependency, raiseOutputWithoutDependency} - from '#composite/control-flow'; -import {withPropertyFromList} from '#composite/data'; +import {withUniqueReferencingThing} from '#composite/wiki-data'; export default templateCompositeFrom({ annotation: `withFlashAct`, @@ -17,42 +12,11 @@ export default templateCompositeFrom({ outputs: ['#flashAct'], steps: () => [ - exitWithoutDependency({ - dependency: 'flashActData', - mode: input.value('null'), + withUniqueReferencingThing({ + data: 'flashActData', + list: input.value('flashes'), + }).outputs({ + ['#uniqueReferencingThing']: '#flashAct', }), - - withPropertyFromList({ - list: 'flashActData', - property: input.value('flashes'), - }), - - { - dependencies: [input.myself(), '#flashActData.flashes'], - compute: (continuation, { - [input.myself()]: track, - ['#flashActData.flashes']: flashLists, - }) => continuation({ - ['#flashActIndex']: - flashLists.findIndex(flashes => flashes.includes(track)), - }), - }, - - raiseOutputWithoutDependency({ - dependency: '#flashActIndex', - mode: input.value('index'), - output: input.value({'#album': null}), - }), - - { - dependencies: ['flashActData', '#flashActIndex'], - compute: (continuation, { - ['flashActData']: flashActData, - ['#flashActIndex']: flashActIndex, - }) => continuation.raiseOutput({ - ['#flashAct']: - flashActData[flashActIndex], - }), - }, ], }); diff --git a/src/data/composite/things/track/withAlbum.js b/src/data/composite/things/track/withAlbum.js index 143e0971..03b840d4 100644 --- a/src/data/composite/things/track/withAlbum.js +++ b/src/data/composite/things/track/withAlbum.js @@ -1,15 +1,10 @@ // Gets the track's album. This will early exit if albumData is missing. // If there's no album whose list of tracks includes this track, the output // dependency will be null. -// -// This step models with Flash.withFlashAct. import {input, templateCompositeFrom} from '#composite'; -import {is} from '#validators'; -import {exitWithoutDependency, raiseOutputWithoutDependency} - from '#composite/control-flow'; -import {withPropertyFromList} from '#composite/data'; +import {withUniqueReferencingThing} from '#composite/wiki-data'; export default templateCompositeFrom({ annotation: `withAlbum`, @@ -17,42 +12,11 @@ export default templateCompositeFrom({ outputs: ['#album'], steps: () => [ - exitWithoutDependency({ - dependency: 'albumData', - mode: input.value('null'), + withUniqueReferencingThing({ + data: 'albumData', + list: input.value('tracks'), + }).outputs({ + ['#uniqueReferencingThing']: '#album', }), - - withPropertyFromList({ - list: 'albumData', - property: input.value('tracks'), - }), - - { - dependencies: [input.myself(), '#albumData.tracks'], - compute: (continuation, { - [input.myself()]: track, - ['#albumData.tracks']: trackLists, - }) => continuation({ - ['#albumIndex']: - trackLists.findIndex(tracks => tracks.includes(track)), - }), - }, - - raiseOutputWithoutDependency({ - dependency: '#albumIndex', - mode: input.value('index'), - output: input.value({'#album': null}), - }), - - { - dependencies: ['albumData', '#albumIndex'], - compute: (continuation, { - ['albumData']: albumData, - ['#albumIndex']: albumIndex, - }) => continuation.raiseOutput({ - ['#album']: - albumData[albumIndex], - }), - }, ], }); |