UNPKG

579 BJavaScriptView Raw
1// Copyright 2017-2022 @polkadot/util authors & contributors
2// SPDX-License-Identifier: Apache-2.0
3import { BigInt } from '@polkadot/x-bigint';
4import { objectSpread } from "../object/spread.js";
5import { u8aToBigInt } from "../u8a/toBigInt.js";
6import { hexToU8a } from "./toU8a.js";
7/**
8 * @name hexToBigInt
9 * @summary Creates a BigInt instance object from a hex string.
10 */
11
12export function hexToBigInt(value, options = {}) {
13 return !value || value === '0x' ? BigInt(0) : u8aToBigInt(hexToU8a(value), objectSpread({
14 isLe: false,
15 isNegative: false
16 }, options));
17}
\No newline at end of file