ES6 Plato on Github
Report Home
Summary Display
components/Helpers.js
Maintainability
61.37
Lines of code
22
Difficulty
24.20
Estimated Errors
0.13
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)) + " TB"; } if (size > (1024 * 1024 * 1024)) { return Math.trunc(size / (1024 * 1024 * 1024)) + " GB"; } if (size > (1024 * 1024)) { return Math.trunc(size / (1024 * 1024)) + " MB"; } if (size > (1024)) { return Math.trunc(size / (1024)) + " KB"; } return size + " Bytes"; }