mirror of
https://github.com/sim1222/misskey.git
synced 2025-07-10 04:39:55 +09:00
なんかもうめっちゃ変えた
This commit is contained in:
6
src/web/app/common/scripts/bytes-to-size.ts
Normal file
6
src/web/app/common/scripts/bytes-to-size.ts
Normal file
@ -0,0 +1,6 @@
|
||||
export default (bytes, digits = 0) => {
|
||||
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
|
||||
if (bytes == 0) return '0Byte';
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(1024));
|
||||
return (bytes / Math.pow(1024, i)).toFixed(digits).replace(/\.0+$/, '') + sizes[i];
|
||||
};
|
Reference in New Issue
Block a user