1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.hexToBn = hexToBn;
|
7 |
|
8 | var _bn = require("../bn/bn");
|
9 |
|
10 | var _boolean = require("../is/boolean");
|
11 |
|
12 | var _spread = require("../object/spread");
|
13 |
|
14 | var _stripPrefix = require("./stripPrefix");
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 | function hexToBn(value) {
|
21 | let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
22 |
|
23 | if (!value || value === '0x') {
|
24 | return new _bn.BN(0);
|
25 | }
|
26 |
|
27 |
|
28 | const {
|
29 | isLe,
|
30 | isNegative
|
31 | } = (0, _spread.objectSpread)({
|
32 | isLe: false,
|
33 | isNegative: false
|
34 | }, (0, _boolean.isBoolean)(options) ? {
|
35 | isLe: options
|
36 | } : options);
|
37 | const stripped = (0, _stripPrefix.hexStripPrefix)(value);
|
38 | const bn = new _bn.BN(stripped, 16, isLe ? 'le' : 'be');
|
39 |
|
40 |
|
41 | return isNegative ? bn.fromTwos(stripped.length * 4) : bn;
|
42 | } |
\ | No newline at end of file |