-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·34 lines (26 loc) · 903 Bytes
/
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
#!/usr/bin/env node
const { getBreaches } = require("./lib");
const argv = process.argv.slice(2);
async function main(count = 20) {
const { avgDiff, breaches } = await getBreaches();
console.log("| TITLE | BREACH DATE | ADDED DATE | DIFF |\n|:------|------------:|-----------:|-----:|");
breaches
.sort((itemA, itemB) => itemB.AddedDiff - itemA.AddedDiff)
.slice(0, count)
// .filter(breach => /\d+/.test(breach.Name))
.forEach(breach => {
let diff = `${breach.AddedDiff}d`;
if (breach.AddedDiff > 365) {
diff = `${(breach.AddedDiff / 365).toFixed(2)}y`;
}
const output = [
breach.Title,
breach.BreachDate.toLocaleDateString(),
breach.AddedDate.toLocaleDateString(),
diff
].join(" | ");
console.log(output);
});
console.log(`\n\nAvg breach->added: ${avgDiff.toFixed(2)}d`);
}
main(...argv);