MCPcopy Create free account
hub / github.com/Datakitpage/Datakit / formatBytes

Function formatBytes

cli-node/lib/system.js:3–8  ·  view source on GitHub ↗
(bytes)

Source from the content-addressed store, hash-verified

1const os = require('os');
2
3function formatBytes(bytes) {
4 const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
5 if (bytes === 0) return '0 Bytes';
6 const i = Math.floor(Math.log(bytes) / Math.log(1024));
7 return Math.round(bytes / Math.pow(1024, i) * 100) / 100 + ' ' + sizes[i];
8}
9
10function getSystemInfo() {
11 const totalMem = os.totalmem();

Callers 1

getSystemInfoFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected