INNER CODE UNIT · JavaScript
formatBytesToKB
puppeteer/examples · code_coverage.js:43
function formatBytesToKB(bytes) {
if (bytes > 1024) {
const formattedNum = new Intl.NumberFormat('en-US', {maximumFractionDigits: 1}).format(bytes / 1024);
return `${formattedNum}KB`;
}
return `${bytes} bytes`;
}
class UsageFormatter {
constructor(stats) {
this.stats = stats;
}
static eventLabel(event) {
// const maxEventLabelLen = EVENTS.reduce((currMax, event) => Math.max(currMax, event.length), 0);
// const eventLabel = event + ' '.repeat(maxEventLabelLen - event.length);
return chalk.magenta(event);
}