-
Notifications
You must be signed in to change notification settings - Fork 34
/
control.js
43 lines (39 loc) · 1023 Bytes
/
control.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
const _ = require("lodash");
const isEqualTo = (pathFrom, compareTo) => value => {
return _.get(value, pathFrom) === compareTo;
};
const returnValue = newValue => () => {
return newValue;
};
const throwError = () => () => {
throw new Error("test");
};
module.exports = {
"control:a.1.0": {
select: [
{ case: isEqualTo("foo", 1), do: returnValue("a") },
{ case: isEqualTo("foo", 2), do: returnValue("b") },
{ default: returnValue("c") }
]
},
"control:a.1.1": {
select: [
{ case: isEqualTo("foo", 2), do: returnValue("a") },
{ case: isEqualTo("foo", 1), do: returnValue("b") },
{ default: returnValue("c") }
]
},
"control:a.1.2": {
select: [
{ case: isEqualTo("foo", 2), do: returnValue("a") },
{ case: isEqualTo("foo", 3), do: returnValue("b") },
{ default: returnValue("c") }
]
},
"control:a.2": {
select: [
{ case: throwError("foo", 2), do: returnValue("a") },
{ default: returnValue("c") }
]
}
};