UNPKG

@okxweb3/coin-stellar

Version:

@ok/coin-stellar is a Stellar SDK for building Web3 wallets and applications. It supports Stellar and PI blockchains, enabling private key management, address generation, transaction signing, trustline creation, and asset transfers

24 lines 801 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.convertWithDecimals = void 0; function convertWithDecimals(numStr, decimals) { if (numStr == '0') { return numStr; } if (!isPositiveIntegerNoZero(numStr)) { throw new RangeError('Number should be a positive integer'); } if (numStr.length <= decimals) { numStr = addLeadingZeros(numStr, decimals + 1); } let position = numStr.length - decimals; return numStr.slice(0, position) + '.' + numStr.slice(position); } exports.convertWithDecimals = convertWithDecimals; function addLeadingZeros(str, length) { return String(str).padStart(length, '0'); } function isPositiveIntegerNoZero(str) { return /^[1-9]\d*$/.test(str); } //# sourceMappingURL=utils.js.map