-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
71 lines (62 loc) · 1.65 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
const cowsay = require('cowsay');
const { rword } = require('rword');
const keypress = require('keypress');
function startKeypress() {
// make `process.stdin` begin emitting "keypress" events
keypress(process.stdin);
// listen for the "keypress" event
process.stdin.on('keypress', function (ch, key) {
if (key && key.name == 'space') {
var next = queue.shift();
if(next){
next();
}
}
if (key && key.ctrl && key.name == 'c') {
process.exit();
}
});
if (process.stdin.setRawMode) {
process.stdin.setRawMode(true);
}
process.stdin.resume();
}
startKeypress();
function clearScreen() {
const readline = require('readline');
const blank = '\n'.repeat(process.stdout.rows);
console.log(blank);
readline.cursorTo(process.stdout, 0, 0);
readline.clearScreenDown(process.stdout);
}
function wordWith(let) {
var re = new RegExp(`^${let}`);
return rword.generate(1, { contains: re, capitalize: 'first' } );
}
function makeCombo() {
return `${wordWith('r')} ${wordWith('p')} ${wordWith('t')} 23`;
}
var makeCombos;
function final1() {
clearScreen();
clearInterval(makeCombos);
console.log('FINAL ANSWER: ');
console.log(cowsay.say({ text: 'prime', e: 'x0' }));
}
function final2() {
clearScreen();
console.log('FINAL ANSWER: ');
console.log(cowsay.say({ text: 'prime prime', e: '0x' }));
}
function final3() {
clearScreen();
console.log('FINAL ANSWER: ');
console.log(cowsay.say({ text: 'prime prime prime', e: 'xx' }));
}
var printCombos = function(){
makeCombos = setInterval(() => {
console.log(makeCombo());
}, 500);
};
var queue = [final1, final2, final3];
printCombos();