-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimer2.js
More file actions
71 lines (67 loc) · 2.04 KB
/
timer2.js
File metadata and controls
71 lines (67 loc) · 2.04 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
const stdin = process.stdin;
stdin.setRawMode(true);
stdin.setEncoding('utf8');
stdin.on('data', (key) => {
if (key === '\u0062') { //
let b = 0;
process.stdout.write('\u0007');
process.stdout.write(`setting timer for ${b} seconds...\n`);
} else if (key === '\u0031') { //
let b = 1;
process.stdout.write(`setting timer for ${b} seconds...\n`);
setTimeout(() => {
process.stdout.write('\u0007');
}, 1000);
} else if (key === '\u0032') { //
let b = 2;
process.stdout.write(`setting timer for ${b} seconds...\n`);
setTimeout(() => {
process.stdout.write('\u0007');
}, 2000);
} else if (key === '\u0033') { //
let b = 3;
process.stdout.write(`setting timer for ${b} seconds...\n`);
setTimeout(() => {
process.stdout.write('\u0007');
}, 3000);
} else if (key === '\u0034') { //
let b = 4;
process.stdout.write(`setting timer for ${b} seconds...\n`);
setTimeout(() => {
process.stdout.write('\u0007');
}, 4000);
} else if (key === '\u0035') { //
let b = 5;
process.stdout.write(`setting timer for ${b} seconds...\n`);
setTimeout(() => {
process.stdout.write('\u0007');
}, 5000);
} else if (key === '\u0036') { //
let b = 6;
process.stdout.write(`setting timer for ${b} seconds...\n`);
setTimeout(() => {
process.stdout.write('\u0007');
}, 6000);
} else if (key === '\u0037') { //
let b = 7;
process.stdout.write(`setting timer for ${b} seconds...\n`);
setTimeout(() => {
process.stdout.write('\u0007');
}, 7000);
} else if (key === '\u0038') { //
let b = 8;
process.stdout.write(`setting timer for ${b} seconds...\n`);
setTimeout(() => {
process.stdout.write('\u0007');
}, 8000);
} else if (key === '\u0039') { //
let b = 9;
process.stdout.write(`setting timer for ${b} seconds...\n`);
setTimeout(() => {
process.stdout.write('\u0007');
}, 9000);
} else if (key === '\u0003') {
console.log("Thanks for using me, ciao!");
process.exit();
}
});