-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathsnapshot.js
129 lines (107 loc) · 2.47 KB
/
snapshot.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
const { ProgressBar } = require('../lib')
console.log()
console.log()
console.log()
console.log()
console.log()
const tokens =
':current.underline.magenta/:total.italic.green :percent.bold.yellow :elapseds.italic.blue :etas.italic.cyan'
const bar0 = new ProgressBar({
schema: ' [:bar] :current/:total :percent :elapseds :etas',
width: 70,
current: 0,
})
const bar1 = new ProgressBar({
schema: ' [:bar] :current/:total :percent :elapseds :etas',
width: 70,
current: 10,
})
const bar2 = new ProgressBar({
schema:
' [.white:filled.brightGreen:blank.brightYellow].white :current.red/:total.grey :percent.green :elapseds :etas',
width: 70,
current: 20,
})
const bar3 = new ProgressBar({
schema: ' [:bar] :current/:total :percent :elapseds :etas',
width: 70,
current: 30,
})
const bar4 = new ProgressBar({
schema: ' [:bar] :current/:total :percent :elapseds :etas',
width: 70,
current: 40,
})
const bar5 = new ProgressBar({
schema:
' [.white:filled.gradient(red,magenta):blank] :current/:total :percent :elapseds :etas',
width: 70,
current: 50,
})
let index = 0
const steps = [
0.1, 0.15, 0.2, 0.25, 0.1, 0.3, 0.35, 0.4, 0.45, 0.2, 0.5, 0.55, 0.6, 0.65,
0.3, 0.3, 0.35, 0.4, 0.45, 0.4, 0.7, 0.75, 0.8, 0.85, 0.4, 0.9, 0.95, 0.8,
0.85, 0.7, 0.8, 1.0,
]
let backward = false
let forward = false
const timer = setInterval(function () {
let color = ''
const current = bar4.current
if (current < 60) {
color = 'red'
} else if (current < 70) {
color = 'magenta'
} else if (current < 80) {
color = 'yellow'
} else if (current < 90) {
color = 'blue'
} else if (current < 100) {
color = 'green'
}
const schema = ` [.white:filled.${color}:blank.grey] .white${tokens}`
bar4.setSchema(schema)
bar0.tick()
// bar1.tick();
if (index < steps.length) {
bar1.update(steps[index])
index += 1
}
bar2.tick()
if (!forward) {
bar3.tick()
if (bar3.current >= 50) {
forward = true
}
} else if (!backward) {
bar3.tick(-1)
if (bar3.current <= 10) {
backward = true
}
} else {
bar3.tick()
}
bar4.tick()
bar5.tick()
if (
bar0.completed &&
bar1.completed &&
bar2.completed &&
bar3.completed &&
bar4.completed &&
bar5.completed
) {
clearInterval(timer)
console.log()
console.log()
console.log()
console.log()
console.log()
}
}, 50)
console.log()
console.log()
console.log()
console.log()
console.log()