improved sizeToReadable
This commit is contained in:
		
							parent
							
								
									1f9757b8a7
								
							
						
					
					
						commit
						58fe46f1de
					
				@ -1,6 +1,7 @@
 | 
			
		||||
function sizeToReadable(size: number): string {
 | 
			
		||||
	const i = Math.floor(Math.log(size) / Math.log(1024))
 | 
			
		||||
	return (size / Math.pow(1024, i)).toFixed(1) + " " + ["B", "kB", "MB", "GB", "TB"][i]
 | 
			
		||||
	const num = (size / Math.pow(1024, i))
 | 
			
		||||
	return (num.toFixed(1).endsWith("0")?num.toFixed(0):num.toFixed(1)) + " " + ["B", "kB", "MB", "GB", "TB"][i]
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user