collect-react-stats
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -86,8 +86,12 @@ #!/usr/bin/env node | ||
/** @type {Array<string | number>[]} */ | ||
const tableData = [["Type", "Total"]]; | ||
const tableData = [["Type", "Total", "Percent"]]; | ||
for (let row of rows) { | ||
tableData.push([row, stats.data[row]]); | ||
tableData.push([ | ||
row, | ||
stats.data[row], | ||
((stats.data[row] / stats.total) * 100).toFixed(2) + "%", | ||
]); | ||
} | ||
tableData.push(["Total", stats.total]); | ||
tableData.push(["Total", stats.total, "100%"]); | ||
@@ -214,7 +218,11 @@ return table(tableData, { border: getBorderCharacters("norc") }); | ||
console.log("Top 20 props passed to DOM VNodes:"); | ||
console.log(">1% props passed to DOM VNodes (min: 20, max 30):"); | ||
const domPropsData = result.summary.domProps.data; | ||
const domPropsTotal = result.summary.domProps.total; | ||
const keys = Object.keys(domPropsData) | ||
.sort((key1, key2) => domPropsData[key2] - domPropsData[key1]) // reverse sort largest to smallest | ||
.slice(0, 20); | ||
.slice(0, 30) | ||
.filter((key, i) => { | ||
return i < 20 || domPropsData[key] / domPropsTotal >= 0.01; | ||
}); | ||
console.log(buildStatsTableFromRow(result.summary.domProps, keys)); | ||
@@ -221,0 +229,0 @@ |
{ | ||
"name": "collect-react-stats", | ||
"type": "module", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "CLI to collect stats about React usage on a website", | ||
@@ -6,0 +6,0 @@ "main": "src/index.js", |
@@ -0,0 +0,0 @@ # collect-react-stats |
Sorry, the diff of this file is not supported yet
647
47005