Initial commit

This commit is contained in:
zhongjin
2020-06-15 10:58:47 +08:00
commit 4f1dfe7564
8590 changed files with 1516878 additions and 0 deletions
@@ -0,0 +1,15 @@
export function humanFileSize (size) {
if (size === 0) {
return '0 B';
}
const i = Math.floor(Math.log(size) / Math.log(1024));
return `${(size / Math.pow(1024, i)).toFixed(2) * 1} ${['B', 'kB', 'MB', 'GB', 'TB'][i]}`;
}
export function numberFormatter (size) {
if (size < 1000) {
return size;
}
const i = Math.floor(Math.log(size) / Math.log(1000));
return `${(size / Math.pow(1000, i)).toFixed(2) * 1}${['k', 'M', 'G'][i - 1]}`;
}