Skip to content

Function: formatFileSize() ​

ts
function formatFileSize(
   bytes, 
   decimals?, 
   binary?): string;

Formats byte size (binary units by default). 文件大小格式化(默认二进制单位)。

Parameters ​

ParameterTypeDefault value
bytesnumberundefined
decimalsnumber2
binarybooleantrue

Returns ​

string

Example ​

ts
formatFileSize(1048576) // => '1.00 MB'

Since ​

1.0.0

Released under the MIT License.