ES6 Plato on Github
Report Home
Summary Display
components/Helpers.js
Maintainability
60.85
Lines of code
22
Difficulty
26.00
Estimated Errors
0.16
Function weight
By Complexity
By SLOC
/** * Returns a friendly readable string with the size * * @param {integer} size Size in bytes * */ export function stringifyBytesSize(size) { if (size > (1024 * 1024 * 1024 *1024)) { return Math.trunc(size / (1024 * 1024 * 1024 * 1024) * 10) / 10 + " TB"; } if (size > (1024 * 1024 * 1024)) { return Math.trunc(size / (1024 * 1024 * 1024) * 10) / 10 + " GB"; } if (size > (1024 * 1024)) { return Math.trunc(size / (1024 * 1024) * 10) / 10 + " MB"; } if (size > (1024)) { return Math.trunc(size / (1024) * 10) / 10 + " KB"; } return size + " Bytes"; }