UNPKG

svg-path-d

Version:

SVG path data (path[d] attribute content) manipulation library.

35 lines 1.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.formatDigit = exports.formatDecimal = void 0; /** * Returns a string representing a number in fixed-point notation. * @param value The number. * @param maximumFractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. */ function formatDecimal(value, maximumFractionDigits) { var str = value.toFixed(maximumFractionDigits); if (/\.\d*$/.test(str)) { var length_1 = str.length; while (true) { if (str.endsWith('0', length_1)) { length_1--; } else { if (str.endsWith('.', length_1)) { length_1--; } break; } } if (length_1 < str.length) { return str.substring(0, length_1); } } return str; } exports.formatDecimal = formatDecimal; function formatDigit(value, fractionDigits) { return ' ' + (fractionDigits < 0 ? value.toString() : formatDecimal(value, fractionDigits)); } exports.formatDigit = formatDigit; //# sourceMappingURL=format.js.map