UNPKG

978 BJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.nToBigInt = nToBigInt;
7
8var _xBigint = require("@polkadot/x-bigint");
9
10var _toBigInt = require("../hex/toBigInt");
11
12var _bn = require("../is/bn");
13
14var _hex = require("../is/hex");
15
16var _toBigInt2 = require("../is/toBigInt");
17
18var _toBn = require("../is/toBn");
19
20// Copyright 2017-2022 @polkadot/util authors & contributors
21// SPDX-License-Identifier: Apache-2.0
22
23/**
24 * @name nToBigInt
25 * @summary Creates a bigInt value from a BN, bigint, string (base 10 or hex) or number input.
26 */
27function nToBigInt(value) {
28 return typeof value === 'bigint' ? value : !value ? (0, _xBigint.BigInt)(0) : (0, _hex.isHex)(value) ? (0, _toBigInt.hexToBigInt)(value.toString()) : (0, _bn.isBn)(value) ? (0, _xBigint.BigInt)(value.toString()) : (0, _toBigInt2.isToBigInt)(value) ? value.toBigInt() : (0, _toBn.isToBn)(value) ? (0, _xBigint.BigInt)(value.toBn().toString()) : (0, _xBigint.BigInt)(value);
29}
\No newline at end of file