1 | ;
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.hexToNumber = hexToNumber;
|
7 |
|
8 | var _toBn = require("./toBn");
|
9 |
|
10 | // Copyright 2017-2022 @polkadot/util authors & contributors
|
11 | // SPDX-License-Identifier: Apache-2.0
|
12 |
|
13 | /**
|
14 | * @name hexToNumber
|
15 | * @summary Creates a Number value from a Buffer object.
|
16 | * @description
|
17 | * `null` inputs returns an NaN result, `hex` values return the actual value as a `Number`.
|
18 | * @example
|
19 | * <BR>
|
20 | *
|
21 | * ```javascript
|
22 | * import { hexToNumber } from '@polkadot/util';
|
23 | *
|
24 | * hexToNumber('0x1234'); // => 0x1234
|
25 | * ```
|
26 | */
|
27 | function hexToNumber(value) {
|
28 | return value ? (0, _toBn.hexToBn)(value).toNumber() : NaN;
|
29 | } |
\ | No newline at end of file |