MCPcopy Create free account
hub / github.com/zxlie/FeHelper / convertBytes

Function convertBytes

apps/byte-unit/byte-utils.js:15–22  ·  view source on GitHub ↗
(value, fromUnit, toUnit)

Source from the content-addressed store, hash-verified

13}
14
15export 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
24export function formatConvertedValue(value) {
25 if (!Number.isFinite(value)) {

Callers 3

index.jsFile · 0.90
byte-utils.test.jsFile · 0.90
getAllConversionsFunction · 0.85

Calls 1

toBytesFunction · 0.85

Tested by

no test coverage detected