feat: TextStats + better searchbar

Signed-off-by: Corentin Thomasset <corentin.thomasset74@gmail.com>
This commit is contained in:
Corentin Thomasset 2020-06-01 18:27:49 +02:00 committed by Corentin THOMASSET
parent 85587beb0d
commit 8c78e8ad77
6 changed files with 177 additions and 54 deletions

View file

@ -12,7 +12,20 @@ const fileIsImage = (file) => {
return file.type.split('/')[0] === 'image';
}
const formatBytes = (bytes, decimals = 2) => {
if (bytes === 0) return '0 Bytes';
const k = 1024;
const dm = decimals < 0 ? 0 : decimals;
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
const i = Math.floor(Math.log(bytes) / Math.log(k));
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
}
export {
copyToClipboard,
fileIsImage
fileIsImage,
formatBytes
}