create local copy of convertBytesToHumanReadable to prevent loading window through indirect import
This commit is contained in:
parent
94e8e501f2
commit
8f19404870
|
@ -1,5 +1,4 @@
|
||||||
import { ElectronFile } from 'types/upload';
|
import { ElectronFile } from 'types/upload';
|
||||||
import { convertBytesToHumanReadable } from 'utils/billing';
|
|
||||||
|
|
||||||
export async function getUint8ArrayView(
|
export async function getUint8ArrayView(
|
||||||
reader: FileReader,
|
reader: FileReader,
|
||||||
|
@ -83,3 +82,16 @@ async function* fileChunkReaderMaker(
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function convertBytesToHumanReadable(
|
||||||
|
bytes: number,
|
||||||
|
precision = 2
|
||||||
|
): string {
|
||||||
|
if (bytes === 0) {
|
||||||
|
return '0 MB';
|
||||||
|
}
|
||||||
|
const i = Math.floor(Math.log(bytes) / Math.log(1024));
|
||||||
|
const sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
||||||
|
|
||||||
|
return (bytes / Math.pow(1024, i)).toFixed(precision) + ' ' + sizes[i];
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue