Cleanup Date.fromNow() and friendlySize()

This commit is contained in:
djmaze 2020-10-03 14:02:33 +02:00
parent 2bd9528098
commit a0f8ac0dad
7 changed files with 28 additions and 50 deletions

View file

@ -99,16 +99,6 @@ export function inFocus() {
return false;
}
/**
* @param {(number|string)} sizeInBytes
* @returns {string}
*/
export function friendlySize(sizeInBytes) {
sizeInBytes = pInt(sizeInBytes);
const sizes = ['B', 'KiB', 'MiB', 'GiB', 'TiB'], i = pInt(Math.floor(Math.log(sizeInBytes) / Math.log(1024)));
return (sizeInBytes / Math.pow(1024, i)).toFixed(2>i ? 0 : 1) + sizes[i];
}
/**
* @param {string} theme
* @returns {string}