MCPcopy Create free account
hub / github.com/unconed/TermKit / formatSize

Function formatSize

HTML/termkit.js:63–75  ·  view source on GitHub ↗
(bytes)

Source from the content-addressed store, hash-verified

61///////////////////////////////////////////////////////////////////////////////
62
63function formatSize(bytes) {
64 var suffixes = ['B', 'KB', 'MB', 'GB', 'TB'];
65 var limit = 1, cap = 1;
66 for (i in suffixes) {
67 limit *= 1000;
68 if (bytes > limit) {
69 cap = limit;
70 }
71 else {
72 return Math.round(bytes / cap * 10) / 10 + ' ' + suffixes[i];
73 }
74 }
75}

Callers 1

outputfactory.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected