« get me outta code hell

withResolvedReverse.js « helpers « wiki-data « composite « data « src - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/composite/wiki-data/helpers/withResolvedReverse.js
blob: 818f60b7babd5d5edb2d3de280a582e8313b7bbe (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
// Actually execute a reverse function.

import {input, templateCompositeFrom} from '#composite';

import inputWikiData from '../inputWikiData.js';

export default templateCompositeFrom({
  annotation: `withReverseReferenceList`,

  inputs: {
    data: inputWikiData({allowMixedTypes: true}),
    reverse: input({type: 'function'}),
    options: input({type: 'object', defaultValue: null}),
  },

  outputs: ['#resolvedReverse'],

  steps: () => [
    {
      dependencies: [
        input.myself(),
        input('data'),
        input('reverse'),
        input('options'),
      ],

      compute: (continuation, {
        [input.myself()]: myself,
        [input('data')]: data,
        [input('reverse')]: reverseFunction,
        [input('options')]: opts,
      }) => continuation({
        ['#resolvedReverse']:
          (data
            ? reverseFunction(myself, data, opts)
            : reverseFunction(myself, opts)),
      }),
    },
  ],
});