UNPKG

800 BJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.hexToBigInt = hexToBigInt;
7
8var _xBigint = require("@polkadot/x-bigint");
9
10var _spread = require("../object/spread");
11
12var _toBigInt = require("../u8a/toBigInt");
13
14var _toU8a = require("./toU8a");
15
16// Copyright 2017-2022 @polkadot/util authors & contributors
17// SPDX-License-Identifier: Apache-2.0
18
19/**
20 * @name hexToBigInt
21 * @summary Creates a BigInt instance object from a hex string.
22 */
23function hexToBigInt(value) {
24 let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
25 return !value || value === '0x' ? (0, _xBigint.BigInt)(0) : (0, _toBigInt.u8aToBigInt)((0, _toU8a.hexToU8a)(value), (0, _spread.objectSpread)({
26 isLe: false,
27 isNegative: false
28 }, options));
29}
\No newline at end of file