-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnyanloader.js
56 lines (47 loc) · 2.02 KB
/
nyanloader.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
const readline = require('readline')
const clc = require('cli-color')
const red = clc.xterm(9)
const ora = clc.xterm(214)
const yel = clc.xterm(226)
const yelB = clc.xterm(11)
const gre = clc.xterm(76)
const blu = clc.xterm(27)
const vio = clc.xterm(63)
const frames = [
' '+red('-')+ora('_')+red('-')+ora('_')+red('-')+ora('_')+red('-')+ora('_')+red('-')+ora('_')+red('-')+ora('_')+red('-')+ora('_')+',------,'+yelB(' o \n')+
' '+gre('_')+yel('-')+gre('_')+yel('-')+gre('_')+yel('-')+gre('_')+yel('-')+gre('_')+yel('-')+gre('_')+yel('-')+gre('_')+yel('-')+'| /\\_/\\'+yelB(' \n')+
' '+blu('-')+vio('_')+blu('-')+vio('_')+blu('-')+vio('_')+blu('-')+vio('_')+blu('-')+vio('_')+blu('-')+vio('_')+blu('-')+'~|__( ^ .^)'+yelB(' + + \n')+
' \"\" \"\" \n',
' '+ora('_')+red('-')+ora('_')+red('-')+ora('_')+red('-')+ora('_')+red('-')+ora('_')+red('-')+ora('_')+red('-')+ora('_')+red('-')+',------,'+yelB(' o + \n')+
' '+yel('-')+gre('_')+yel('-')+gre('_')+yel('-')+gre('_')+yel('-')+gre('_')+yel('-')+gre('_')+yel('-')+gre('_')+yel('-')+gre('_')+'| /\\_/\\'+yelB(' + \n')+
' '+vio('_')+blu('-')+vio('_')+blu('-')+vio('_')+blu('-')+vio('_')+blu('-')+vio('_')+blu('-')+vio('_')+blu('-')+vio('_')+'~|__( o .o)'+yelB(' o \n')+
'Loading . . . \"\" \"\" \n'
]
class NyanLoader {
constructor() {
this.rl = readline.createInterface({
input: process.stdin,
output: process.stdout
})
this.frame = 0
this.animation = this.start()
}
start() {
var self = this;
if(!this.animation) {
this.animation = setInterval(() => {
self.frame && process.stdout.write(clc.bol(-4))
self.rl.write(frames[++self.frame % 2])
}, 200);
}
return this.animation
}
stop() {
clearInterval(this.animation)
this.animation = null
this.frame = 0
process.stdout.write(clc.bol(-1))
this.rl.write(' \n')
}
}
module.exports = new NyanLoader()