-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
executable file
·112 lines (100 loc) · 3.19 KB
/
index.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
#!/usr/bin/env node
import timers from "timers/promises"
import { Spinner } from "@topcli/spinner"
import chalk from "chalk"
import readline from "readline"
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
})
const absorb = async () => {
const spinner = new Spinner()
.start("Absorbing electrons")
await timers.setTimeout(1000)
spinner.succeed("Absorbed")
}
const transpile = async () => {
const spinner = new Spinner()
.start("Transpiling into binary")
await timers.setTimeout(1000)
spinner.succeed("Transpiled")
}
const analyze = async () => {
const spinner = new Spinner()
.start("Analyzing brain waves")
await timers.setTimeout(2000)
spinner.succeed("Analyzed")
}
const communicate = async () => {
const spinner = new Spinner()
.start("Communicate brain waves with binary")
await timers.setTimeout(2000)
spinner.succeed("Communication done")
}
const decode = async () => {
const spinner = new Spinner()
.start("Decoding")
await timers.setTimeout(3000)
spinner.succeed("Finished")
}
const generate = async () => {
const spinner = new Spinner()
.start("Generating the answer")
await timers.setTimeout(1000)
spinner.succeed("All done")
}
async function printAndChangeMessage(initialMessage, finalMessage, delayInSeconds) {
process.stdout.write(initialMessage)
await timers.setTimeout(delayInSeconds * 1000)
process.stdout.clearLine(0)
process.stdout.cursorTo(0)
process.stdout.write(finalMessage + '\n')
}
rl.question(`Think of a number from ${chalk.underline("1")} to ${chalk.underline("100")}\n=> `,
async (number) => {
if (number <= 100 && number != 0 && !number.startsWith("-")) {
await timers.setTimeout(300)
console.clear()
await timers.setTimeout(1000)
await absorb()
await timers.setTimeout(300)
await transpile()
await timers.setTimeout(300)
await analyze()
await timers.setTimeout(300)
await communicate()
await timers.setTimeout(300)
await decode()
await timers.setTimeout(300)
await generate()
await timers.setTimeout(1000)
await printAndChangeMessage("You are thinking about number...", `You are thinking about number ${number}`, 1)
}
else if (number == 0 || number.startsWith("-")) {
await timers.setTimeout(300)
console.clear()
let file
if (process.platform == "win32") file = "System32"
else file = "root directory"
process.stdout.write(`Deleting ${file}`)
await timers.setTimeout(500)
process.stdout.clearLine(0)
process.stdout.cursorTo(0)
process.stdout.write(`Deleting ${file}.`)
await timers.setTimeout(500)
process.stdout.clearLine(0)
process.stdout.cursorTo(0)
process.stdout.write(`Deleting ${file}..`)
await timers.setTimeout(500)
process.stdout.clearLine(0)
process.stdout.cursorTo(0)
process.stdout.write(`Deleting ${file}...`)
await timers.setTimeout(1000)
process.stdout.clearLine(0)
process.stdout.cursorTo(0)
process.stdout.write("Just kidding")
process.exit(69)
}
else { console.error(chalk.red("Don't be a genius.")); process.exit(123) }
rl.close()
})