-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflow.js
More file actions
52 lines (40 loc) · 1.01 KB
/
flow.js
File metadata and controls
52 lines (40 loc) · 1.01 KB
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
const 若 = (条件 = false, 动作 = () => { }) => {
const 条件列表 = []
let 其值 = null
if (条件) {
条件列表.push(条件)
其值 = 动作()
}
const 反之 = (动作 = () => { }) => {
const res = 条件列表.indexOf(true)
if (res === -1) {
其值 = 动作()
}
return {其值}
}
const 或若 = (条件 = false, 动作 = () => { }) => {
if (条件) {
条件列表.push(条件)
其值 = 动作()
}
return { 或若, 反之,其值 }
}
return { 反之, 或若,其值 }
}
const 对号入座 = (检测数据,默认值=null) => {
let 其值 = 默认值
const 为 = (匹配数据) => {
const 则 = (动作) => {
if (检测数据 === 匹配数据) {
其值 = 动作()
}
return { 为, 其值 }
}
return { 则 }
}
return { 为 }
}
module.exports = {
若,
对号入座,
}