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
  | 
import {input, templateCompositeFrom} from '#composite';
import {raiseOutputWithoutDependency} from '#composite/control-flow';
export default templateCompositeFrom({
  annotation: `withWebArchiveDate`,
  outputs: ['#webArchiveDate'],
  steps: () => [
    {
      dependencies: ['annotation'],
      compute: (continuation, {annotation}) =>
        continuation({
          ['#dateText']:
            annotation
              ?.match(/https?:\/\/web.archive.org\/web\/([0-9]{8,8})[0-9]*\//)
              ?.[1] ??
            null,
        }),
    },
    raiseOutputWithoutDependency({
      dependency: '#dateText',
      output: input.value({['#webArchiveDate']: null}),
    }),
    {
      dependencies: ['#dateText'],
      compute: (continuation, {['#dateText']: dateText}) =>
        continuation({
          ['#webArchiveDate']:
            new Date(
              dateText.slice(0, 4) + '/' +
              dateText.slice(4, 6) + '/' +
              dateText.slice(6, 8)),
        }),
    },
  ],
});
  |