chedder
Version:
29 lines • 750 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.addCommas = exports.yton = void 0;
// 5 decimals and thousands sep
function yton(yoctos) {
let units = yoctos;
if (units.length < 25)
units = units.padStart(25, '0');
units = units.slice(0, -24) + "." + units.slice(-24, -19);
return addCommas(units);
}
exports.yton = yton;
/**
* adds commas to a string number
* @param {string} str
*/
function addCommas(str) {
let n = str.indexOf(".");
if (n == -1)
n = str.length;
n -= 4;
while (n >= 0) {
str = str.slice(0, n + 1) + "," + str.slice(n + 1);
n = n - 3;
}
return str;
}
exports.addCommas = addCommas;
//# sourceMappingURL=conversion.js.map