UNPKG

427 BJavaScriptView Raw
1import { BigInt } from '@polkadot/x-bigint';
2import { u8aToBigInt } from '../u8a/toBigInt.js';
3import { hexToU8a } from './toU8a.js';
4/**
5 * @name hexToBigInt
6 * @summary Creates a BigInt instance object from a hex string.
7 */
8export function hexToBigInt(value, { isLe = false, isNegative = false } = {}) {
9 return !value || value === '0x'
10 ? BigInt(0)
11 : u8aToBigInt(hexToU8a(value), { isLe, isNegative });
12}