MCPcopy Create free account
hub / github.com/GlobalTechInfo/MEGA-MD / formatBytes

Function formatBytes

plugins/mega.js:3–10  ·  view source on GitHub ↗
(bytes)

Source from the content-addressed store, hash-verified

1import { File } from 'megajs';
2import path from 'path';
3const formatBytes = (bytes) => {
4 if (bytes === 0)
5 return '0 Bytes';
6 const k = 1024;
7 const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
8 const i = Math.floor(Math.log(bytes) / Math.log(k));
9 return `${parseFloat((bytes / Math.pow(k, i)).toFixed(2)) } ${ sizes[i]}`;
10};
11const generateBar = (percentage) => {
12 const totalBars = 10;
13 const filledBars = Math.floor((percentage / 100) * totalBars);

Callers 1

handlerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected