-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrules.js
94 lines (90 loc) · 1.84 KB
/
rules.js
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
'use strict'
const {matchers: db} = require('./db')
const {matchers: pkp} = require('./pkp')
const {matchers: sncb} = require('./sncb')
const {matchers: vbb} = require('./vbb')
const {matchers: hvv} = require('./hvv')
const {matchers: insa} = require('./insa')
const withRetVal = (retVal, matchers) => {
return Object.entries(matchers)
.map(([name, testFn]) => [name, testFn, retVal])
}
const matchers = {
db: {
pkp: [
...withRetVal(true, db.pkp),
...withRetVal(false, db.self),
],
sncb: [
...withRetVal(true, db.sncb),
...withRetVal(false, db.self),
],
vbb: [
...withRetVal(true, db.vbb),
...withRetVal(false, db.self),
],
hvv: [
...withRetVal(true, db.hvv),
...withRetVal(false, db.self),
],
insa: [
...withRetVal(true, db.insa),
...withRetVal(false, db.self),
],
},
pkp: {
db: [
...withRetVal(true, pkp.db),
...withRetVal(false, pkp.self),
],
cd: [
...withRetVal(true, pkp.cd),
...withRetVal(false, pkp.self),
],
vbb: [
...withRetVal(true, pkp.vbb),
...withRetVal(false, pkp.self),
],
},
sncb: {
db: [
...withRetVal(true, sncb.db),
...withRetVal(false, sncb.self),
],
},
vbb: {
db: [
...withRetVal(true, vbb.db),
...withRetVal(false, vbb.self),
vbb.bob,
],
pkp: [
...withRetVal(true, vbb.pkp),
...withRetVal(false, vbb.self),
vbb.bob,
],
insa: [
...withRetVal(true, vbb.insa),
...withRetVal(false, vbb.self),
],
},
hvv: {
db: [
['regionalTrain', hvv.regionalTrain, true],
['regionalExpressTrain', hvv.regionalExpressTrain, true],
['longDistanceTrain', hvv.longDistanceTrain, true],
...withRetVal(false, hvv.self),
],
},
insa: {
db: [
...withRetVal(true, insa.db),
...withRetVal(false, insa.self),
],
vbb: [
...withRetVal(true, insa.vbb),
...withRetVal(false, insa.self),
],
},
}
module.exports = matchers