mirror of
https://github.com/pezkuwichain/pezkuwi-common.git
synced 2026-04-23 03:48:00 +00:00
24 lines
598 B
JavaScript
24 lines
598 B
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.hexToNumber = hexToNumber;
|
|
const toBn_js_1 = require("./toBn.js");
|
|
/**
|
|
* @name hexToNumber
|
|
* @summary Creates a Number value from a Buffer object.
|
|
* @description
|
|
* `null` inputs returns an NaN result, `hex` values return the actual value as a `Number`.
|
|
* @example
|
|
* <BR>
|
|
*
|
|
* ```javascript
|
|
* import { hexToNumber } from '@pezkuwi/util';
|
|
*
|
|
* hexToNumber('0x1234'); // => 0x1234
|
|
* ```
|
|
*/
|
|
function hexToNumber(value) {
|
|
return value
|
|
? (0, toBn_js_1.hexToBn)(value).toNumber()
|
|
: NaN;
|
|
}
|