🪖 Moves humanFileSize to string utilities

This commit is contained in:
Rune Harlyk
2024-02-22 23:47:25 +01:00
parent 74bf4a8656
commit 162b148973
4 changed files with 8 additions and 6 deletions
+2
View File
@@ -0,0 +1,2 @@
export * from './result'
export * from './string-utilities'
@@ -0,0 +1,5 @@
export const humanFileSize = (size:number):string => {
const units = ['B', 'kB', 'MB', 'GB', 'TB']
var i = size == 0 ? 0 : Math.floor(Math.log(size) / Math.log(1024));
return Number((size / Math.pow(1024, i)).toFixed(2)) * 1 + units[i];
}