UNPKG

emmet.sdk

Version:
22 lines 729 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.humanToBigInt = void 0; const replaceAll_1 = require("./replaceAll"); function humanToBigInt(n, decimals = 18) { if (!n || (typeof n === 'string' && n.includes('NaN'))) { return 0n; } let value, whole, fraction; value = (0, replaceAll_1.replaceAll)(n, ",", ''); [whole, fraction] = value.split('.'); if (!fraction) { fraction = ''; } const _dec = typeof decimals === 'string' ? parseInt(decimals) : decimals; while (fraction.length < _dec) { fraction += '0'; } return BigInt(whole + fraction); } exports.humanToBigInt = humanToBigInt; //# sourceMappingURL=humanToBigInt.js.map