MCPcopy
hub / github.com/microsoft/SandDance / formatValue

Function formatValue

docs/app/js/sanddance-app.js:58472–58484  ·  view source on GitHub ↗
(v)

Source from the content-addressed store, hash-verified

58470 return "".concat(string).concat(" ".repeat(padLength));
58471}
58472function formatValue(v) {
58473 let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
58474 const EPSILON = 1e-16;
58475 const { isInteger =false } = opts;
58476 if (Array.isArray(v) || ArrayBuffer.isView(v)) return formatArrayValue(v, opts);
58477 if (!Number.isFinite(v)) return String(v);
58478 if (Math.abs(v) < EPSILON) return isInteger ? "0" : "0.";
58479 if (isInteger) return v.toFixed(0);
58480 if (Math.abs(v) > 100 && Math.abs(v) < 10000) return v.toFixed(0);
58481 const string = v.toPrecision(2);
58482 const decimal = string.indexOf(".0");
58483 return decimal === string.length - 2 ? string.slice(0, -1) : string;
58484}
58485function formatArrayValue(v, opts) {
58486 const { maxElts =16 , size =1 } = opts;
58487 let string = "[";

Callers 4

formatArrayValueFunction · 0.70
preformatBodyFunction · 0.70
formatRangeFunction · 0.70
formatObjectFunction · 0.70

Calls 4

replaceMethod · 0.80
formatArrayValueFunction · 0.70
roundFunction · 0.70
formatDateFunction · 0.70

Tested by

no test coverage detected