emmet.sdk
Version:
Emmet.Bridge SDK library
16 lines • 567 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.stringToBigNum = void 0;
const stringToBigNum = (amount, decimals = 18) => {
let result = 0n;
if (amount && typeof amount === 'string') {
const cleaned = amount.replace(',', '').replace('.', '');
if (/^[0-9]+$/.test(cleaned)) {
const multiplier = 10n ** BigInt(decimals);
result = (BigInt(cleaned) * multiplier);
}
}
return result;
};
exports.stringToBigNum = stringToBigNum;
//# sourceMappingURL=stringToBigNum.js.map