MCPcopy Index your code
hub / github.com/nodejs/node / formatBytes

Function formatBytes

deps/v8/tools/js/helper.mjs:11–20  ·  view source on GitHub ↗
(bytes, digits = 2)

Source from the content-addressed store, hash-verified

9export const kMicro2Milli = 1 / 1000;
10
11export function formatBytes(bytes, digits = 2) {
12 const units = ['B', 'KiB', 'MiB', 'GiB'];
13 const divisor = 1024;
14 let index = 0;
15 while (index < units.length && bytes >= divisor) {
16 index++;
17 bytes /= divisor;
18 }
19 return bytes.toFixed(digits) + units[index];
20}
21
22export function formatMicroSeconds(micro) {
23 return (micro * kMicro2Milli).toFixed(1) + 'ms';

Callers 6

BYTESFunction · 0.90
updateProgressBarMethod · 0.90
toolTipDictMethod · 0.90
entryMethod · 0.90
_entrySummaryMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…