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

Function formatConvertedValue

apps/byte-unit/byte-utils.js:24–32  ·  view source on GitHub ↗
(value)

Source from the content-addressed store, hash-verified

22}
23
24export function formatConvertedValue(value) {
25 if (!Number.isFinite(value)) {
26 return '';
27 }
28 if (Math.abs(value) >= 100 || Number.isInteger(value)) {
29 return String(Math.round(value * 1000000) / 1000000).replace(/\.0+$/, '').replace(/(\.\d*?)0+$/, '$1');
30 }
31 return value.toFixed(6).replace(/\.0+$/, '').replace(/(\.\d*?)0+$/, '$1');
32}
33
34export function getAllConversions(value, fromUnit) {
35 return BYTE_UNITS.map((unit) => ({

Callers 3

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

Calls

no outgoing calls

Tested by

no test coverage detected