-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo.js
More file actions
38 lines (34 loc) · 1.35 KB
/
demo.js
File metadata and controls
38 lines (34 loc) · 1.35 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
const RandExp = require("randexp");
const fs = require("fs");
const RandomChecker = require(".");
let demo = '\u001b[34m[Demo]\u001b[0m';
let total = '\u001b[32m[Total]\u001b[0m';
let humans = '\u001b[36mHumans\u001b[0m:';
let robots = '\u001b[31mRobots\u001b[0m:';
(async () => {
console.log(demo, `${humans.replace(':','')} vs ${robots.replace(':','')}: The Final Match`);
await sleep(650);
let rc = new RandomChecker();
let wordlist = fs.readFileSync('wordlist', 'utf-8').trim().split(' ');
let randex = new RandExp(/[a-z0-9]{10}/);
let totalHuman = 0;
let totalRobot = 0;
const max = 50000;
for (let i = 0; i < max; i++) {
let text = wordlist[i];
let human = await rc.check(text);
totalHuman += human;
console.log(demo, humans, `${text}:`, human, ' '.repeat(40 - (human.toString().length + text.length)), `${(i/max*100).toFixed(1)}%`);
let random = randex.gen();
let robot = await rc.check(random);
totalRobot += robot;
console.log(demo, robots, `${random}:`, robot, ' '.repeat(40 - (robot.toString().length + random.length)), `${(i/max*100).toFixed(1)}%`);
}
console.log(total, humans, totalHuman);
console.log(total, robots, totalRobot);
})();
function sleep(ms) {
return new Promise(async (resolve, reject) => {
setTimeout(resolve, ms);
});
}