mirror of
https://github.com/pezkuwichain/pezkuwi-common.git
synced 2026-06-17 21:51:07 +00:00
chore: update to version 14.0.11 and align website URLs
This commit is contained in:
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* @summary Utility methods to convert to and from `number` values
|
||||
*/
|
||||
export { numberToHex } from './toHex.js';
|
||||
export { numberToU8a } from './toU8a.js';
|
||||
@@ -0,0 +1,10 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.numberToU8a = exports.numberToHex = void 0;
|
||||
/**
|
||||
* @summary Utility methods to convert to and from `number` values
|
||||
*/
|
||||
var toHex_js_1 = require("./toHex.js");
|
||||
Object.defineProperty(exports, "numberToHex", { enumerable: true, get: function () { return toHex_js_1.numberToHex; } });
|
||||
var toU8a_js_1 = require("./toU8a.js");
|
||||
Object.defineProperty(exports, "numberToU8a", { enumerable: true, get: function () { return toU8a_js_1.numberToU8a; } });
|
||||
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
import type { HexString } from '../types.js';
|
||||
/**
|
||||
* @name numberToHex
|
||||
* @summary Creates a hex value from a number.
|
||||
* @description
|
||||
* `null`/`undefined`/`NaN` inputs returns an empty `0x` result. `number` input values return the actual bytes value converted to a `hex`. With `bitLength` set, it converts the number to the equivalent size.
|
||||
* @example
|
||||
* <BR>
|
||||
*
|
||||
* ```javascript
|
||||
* import { numberToHex } from '@pezkuwi/util';
|
||||
*
|
||||
* numberToHex(0x1234); // => '0x1234'
|
||||
* numberToHex(0x1234, 32); // => 0x00001234
|
||||
* ```
|
||||
*/
|
||||
export declare function numberToHex(value?: number | null, bitLength?: number): HexString;
|
||||
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.numberToHex = numberToHex;
|
||||
const fixLength_js_1 = require("../hex/fixLength.js");
|
||||
/**
|
||||
* @name numberToHex
|
||||
* @summary Creates a hex value from a number.
|
||||
* @description
|
||||
* `null`/`undefined`/`NaN` inputs returns an empty `0x` result. `number` input values return the actual bytes value converted to a `hex`. With `bitLength` set, it converts the number to the equivalent size.
|
||||
* @example
|
||||
* <BR>
|
||||
*
|
||||
* ```javascript
|
||||
* import { numberToHex } from '@pezkuwi/util';
|
||||
*
|
||||
* numberToHex(0x1234); // => '0x1234'
|
||||
* numberToHex(0x1234, 32); // => 0x00001234
|
||||
* ```
|
||||
*/
|
||||
function numberToHex(value, bitLength = -1) {
|
||||
const hex = (!value || Number.isNaN(value) ? 0 : value).toString(16);
|
||||
return (0, fixLength_js_1.hexFixLength)(hex.length % 2 ? `0${hex}` : hex, bitLength, true);
|
||||
}
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* @name numberToU8a
|
||||
* @summary Creates a Uint8Array object from a number.
|
||||
* @description
|
||||
* `null`/`undefined`/`NaN` inputs returns an empty `Uint8Array` result. `number` input values return the actual bytes value converted to a `Uint8Array`. With `bitLength`, it converts the value to the equivalent size.
|
||||
* @example
|
||||
* <BR>
|
||||
*
|
||||
* ```javascript
|
||||
* import { numberToU8a } from '@pezkuwi/util';
|
||||
*
|
||||
* numberToU8a(0x1234); // => [0x12, 0x34]
|
||||
* ```
|
||||
*/
|
||||
export declare function numberToU8a(value?: number | null, bitLength?: number): Uint8Array;
|
||||
@@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.numberToU8a = numberToU8a;
|
||||
const toU8a_js_1 = require("../hex/toU8a.js");
|
||||
const toHex_js_1 = require("./toHex.js");
|
||||
/**
|
||||
* @name numberToU8a
|
||||
* @summary Creates a Uint8Array object from a number.
|
||||
* @description
|
||||
* `null`/`undefined`/`NaN` inputs returns an empty `Uint8Array` result. `number` input values return the actual bytes value converted to a `Uint8Array`. With `bitLength`, it converts the value to the equivalent size.
|
||||
* @example
|
||||
* <BR>
|
||||
*
|
||||
* ```javascript
|
||||
* import { numberToU8a } from '@pezkuwi/util';
|
||||
*
|
||||
* numberToU8a(0x1234); // => [0x12, 0x34]
|
||||
* ```
|
||||
*/
|
||||
function numberToU8a(value, bitLength = -1) {
|
||||
return (0, toU8a_js_1.hexToU8a)((0, toHex_js_1.numberToHex)(value, bitLength));
|
||||
}
|
||||
Reference in New Issue
Block a user