We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 09b027f commit cb744a0Copy full SHA for cb744a0
src/lib/file.ts
@@ -117,7 +117,7 @@ export const FileUtil = {
117
throw new Error("SparkMD5 not found");
118
}
119
const reader = stream.getReader();
120
- const spark = new SparkMD5.ArrayBuffer();
+ const spark: any = new SparkMD5.ArrayBuffer();
121
122
return new Promise((resolve, reject) => {
123
function processChunk() {
@@ -142,4 +142,11 @@ export const FileUtil = {
142
processChunk();
143
});
144
},
145
+ formatSize: (bytes: number) => {
146
+ if (bytes === 0) return '0 Bytes';
147
+ const k = 1024;
148
+ const sizes = ['Bytes', 'KB', 'MB', 'GB'];
149
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
150
+ return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
151
+ },
152
};
0 commit comments