forked from Laboratoria/bog001-md-links
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstats.js
More file actions
23 lines (21 loc) · 686 Bytes
/
stats.js
File metadata and controls
23 lines (21 loc) · 686 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const fs = require('fs');
const path = require('path');
// estadisticas de mis links
const estadisticas = (linksValidate, validateBroken) => {
const filtroLinks = linksValidate.filter((element) => {
return element.validate == "fail"
})
const totalLinks = linksValidate.length
const linkRotos = filtroLinks.length
const linksUnicos = [...new Set(linksValidate.map((uno) => uno.href))].length;
const statsLinks = `
Total: ${totalLinks}
unique: ${linksUnicos}`;
const linkBroken = `${statsLinks}\n broken: ${linkRotos}`;
if (validateBroken) {
console.log(linkBroken);
return linkBroken
}
return statsLinks
}
module.exports = estadisticas