The number of bytes to format. 要格式化的字节数
Formatting options. 格式化选项
Optionalbinary?: booleanWhether to use binary units (1024 base) instead of decimal units (1000 base). Defaults to false. 是否使用二进制单位(以 1024 为基数)而非十进制单位(以 1000 为基数)。默认为 false
Optionalprecision?: numberNumber of decimal places to keep. Defaults to 1. 保留的小数位数。默认为 1
Optionalwhitespace?: booleanWhether to include whitespace between the number and the unit. Defaults to false. 是否保留数字与单位之间的空格。默认为 false
The formatted string. 格式化后的字符串
Formats a number of bytes into a human-readable string.
Uses decimal units (1000 base, e.g. KB, MB) by default, or binary units (1024 base, e.g. KiB, MiB) when
binaryis true. Values below the base are returned as-is with theBunit and no decimal places.将字节数格式化为人类可读的字符串。
默认使用十进制单位(以 1000 为基数,如 KB、MB);当
binary为 true 时使用 二进制单位(以 1024 为基数,如 KiB、MiB)。小于基数的值原样返回并附带B单位, 不保留小数位。