(value, fromUnit, toUnit)
| 13 | } |
| 14 | |
| 15 | export function convertBytes(value, fromUnit, toUnit) { |
| 16 | const bytes = toBytes(value, fromUnit); |
| 17 | const targetIndex = BYTE_UNITS.indexOf(toUnit); |
| 18 | if (targetIndex === -1) { |
| 19 | throw new Error('不支持的单位'); |
| 20 | } |
| 21 | return bytes / Math.pow(1024, targetIndex); |
| 22 | } |
| 23 | |
| 24 | export function formatConvertedValue(value) { |
| 25 | if (!Number.isFinite(value)) { |
no test coverage detected