MCPcopy Create free account
hub / github.com/MALSync/MALSync / conditionalPageInterfaces

Function conditionalPageInterfaces

src/pages-chibi/implementations/bato/main.ts:6–55  ·  view source on GitHub ↗
(
  condition: (c: ChibiGenerator<any>) => ChibiJson<boolean>,
  interface1: PageInterface,
  interface2: PageInterface,
)

Source from the content-addressed store, hash-verified

4import { batoV3 } from './mainV3';
5
6function conditionalPageInterfaces(
7 condition: (c: ChibiGenerator<any>) => ChibiJson<boolean>,
8 interface1: PageInterface,
9 interface2: PageInterface,
10): PageInterface {
11 const final = interface1;
12
13 [
14 'isSyncPage',
15 'getTitle',
16 'getIdentifier',
17 'getOverviewUrl',
18 'getEpisode',
19 'getVolume',
20 'nextEpUrl',
21 'getImage',
22 ].forEach(method => {
23 final.sync[method] = conditionalMethod(
24 condition,
25 interface1.sync[method],
26 interface2.sync[method],
27 ) as any;
28 });
29
30 ['isOverviewPage', 'getTitle', 'getIdentifier', 'uiInjection', 'getImage'].forEach(method => {
31 final.overview![method] = conditionalMethod(
32 condition,
33 interface1.overview![method],
34 interface2.overview![method],
35 ) as any;
36 });
37
38 ['elementsSelector', 'elementUrl', 'elementEp'].forEach(method => {
39 final.list![method] = conditionalMethod(
40 condition,
41 interface1.list![method],
42 interface2.list![method],
43 ) as any;
44 });
45
46 ['setup'].forEach(method => {
47 final.lifecycle[method] = conditionalMethod(
48 condition,
49 interface1.lifecycle[method],
50 interface2.lifecycle[method],
51 ) as any;
52 });
53
54 return final;
55}
56
57function conditionalMethod(
58 condition: (c: ChibiGenerator<any>) => ChibiJson<boolean>,

Callers 1

main.tsFile · 0.85

Calls 1

conditionalMethodFunction · 0.85

Tested by

no test coverage detected