MCPcopy Create free account
hub / github.com/atomicdata-dev/atomic-data-browser / niceBytes

Function niceBytes

data-browser/src/views/FilePage.tsx:65–73  ·  view source on GitHub ↗
(n: number)

Source from the content-addressed store, hash-verified

63const units = ['bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
64
65function niceBytes(n: number) {
66 let l = 0;
67
68 while (n >= 1024 && ++l) {
69 n = n / 1024;
70 }
71
72 return n.toFixed(n < 10 && l > 0 ? 1 : 0) + ' ' + units[l];
73}

Callers 1

FileInnerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected