chore: update to version 14.0.11 and align website URLs

This commit is contained in:
2026-01-11 11:34:13 +03:00
parent ef74383349
commit 19c8d69bd8
1499 changed files with 53633 additions and 89 deletions
+2
View File
@@ -0,0 +1,2 @@
import BN from 'bn.js';
export { BN };
+6
View File
@@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BN = void 0;
const tslib_1 = require("tslib");
const bn_js_1 = tslib_1.__importDefault(require("bn.js"));
exports.BN = bn_js_1.default;
+91
View File
@@ -0,0 +1,91 @@
import { BN } from './bn.js';
/**
* @name BN_ZERO
* @summary BN constant for 0.
*/
export declare const BN_ZERO: BN;
/**
* @name BN_ONE
* @summary BN constant for 1.
*/
export declare const BN_ONE: BN;
/**
* @name BN_TWO
* @summary BN constant for 2.
*/
export declare const BN_TWO: BN;
/**
* @name BN_THREE
* @summary BN constant for 3.
*/
export declare const BN_THREE: BN;
/**
* @name BN_FOUR
* @summary BN constant for 4.
*/
export declare const BN_FOUR: BN;
/**
* @name BN_FIVE
* @summary BN constant for 5.
*/
export declare const BN_FIVE: BN;
/**
* @name BN_SIX
* @summary BN constant for 6.
*/
export declare const BN_SIX: BN;
/**
* @name BN_SEVEN
* @summary BN constant for 7.
*/
export declare const BN_SEVEN: BN;
/**
* @name BN_EIGHT
* @summary BN constant for 8.
*/
export declare const BN_EIGHT: BN;
/**
* @name BN_NINE
* @summary BN constant for 9.
*/
export declare const BN_NINE: BN;
/**
* @name BN_TEN
* @summary BN constant for 10.
*/
export declare const BN_TEN: BN;
/**
* @name BN_HUNDRED
* @summary BN constant for 100.
*/
export declare const BN_HUNDRED: BN;
/**
* @name BN_THOUSAND
* @summary BN constant for 1,000.
*/
export declare const BN_THOUSAND: BN;
/**
* @name BN_MILLION
* @summary BN constant for 1,000,000.
*/
export declare const BN_MILLION: BN;
/**
* @name BN_BILLION
* @summary BN constant for 1,000,000,000.
*/
export declare const BN_BILLION: BN;
/**
* @name BN_QUINTILL
* @summary BN constant for 1,000,000,000,000,000,000.
*/
export declare const BN_QUINTILL: BN;
/**
* @name BN_MAX_INTEGER
* @summary BN constant for MAX_SAFE_INTEGER
*/
export declare const BN_MAX_INTEGER: BN;
/**
* @name BN_SQRT_MAX_INTEGER
* @summary BN constant for Math.sqrt(MAX_SAFE_INTEGER)
*/
export declare const BN_SQRT_MAX_INTEGER: BN;
+94
View File
@@ -0,0 +1,94 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BN_SQRT_MAX_INTEGER = exports.BN_MAX_INTEGER = exports.BN_QUINTILL = exports.BN_BILLION = exports.BN_MILLION = exports.BN_THOUSAND = exports.BN_HUNDRED = exports.BN_TEN = exports.BN_NINE = exports.BN_EIGHT = exports.BN_SEVEN = exports.BN_SIX = exports.BN_FIVE = exports.BN_FOUR = exports.BN_THREE = exports.BN_TWO = exports.BN_ONE = exports.BN_ZERO = void 0;
const bn_js_1 = require("./bn.js");
/**
* @name BN_ZERO
* @summary BN constant for 0.
*/
exports.BN_ZERO = new bn_js_1.BN(0);
/**
* @name BN_ONE
* @summary BN constant for 1.
*/
exports.BN_ONE = new bn_js_1.BN(1);
/**
* @name BN_TWO
* @summary BN constant for 2.
*/
exports.BN_TWO = new bn_js_1.BN(2);
/**
* @name BN_THREE
* @summary BN constant for 3.
*/
exports.BN_THREE = new bn_js_1.BN(3);
/**
* @name BN_FOUR
* @summary BN constant for 4.
*/
exports.BN_FOUR = new bn_js_1.BN(4);
/**
* @name BN_FIVE
* @summary BN constant for 5.
*/
exports.BN_FIVE = new bn_js_1.BN(5);
/**
* @name BN_SIX
* @summary BN constant for 6.
*/
exports.BN_SIX = new bn_js_1.BN(6);
/**
* @name BN_SEVEN
* @summary BN constant for 7.
*/
exports.BN_SEVEN = new bn_js_1.BN(7);
/**
* @name BN_EIGHT
* @summary BN constant for 8.
*/
exports.BN_EIGHT = new bn_js_1.BN(8);
/**
* @name BN_NINE
* @summary BN constant for 9.
*/
exports.BN_NINE = new bn_js_1.BN(9);
/**
* @name BN_TEN
* @summary BN constant for 10.
*/
exports.BN_TEN = new bn_js_1.BN(10);
/**
* @name BN_HUNDRED
* @summary BN constant for 100.
*/
exports.BN_HUNDRED = new bn_js_1.BN(100);
/**
* @name BN_THOUSAND
* @summary BN constant for 1,000.
*/
exports.BN_THOUSAND = new bn_js_1.BN(1_000);
/**
* @name BN_MILLION
* @summary BN constant for 1,000,000.
*/
exports.BN_MILLION = new bn_js_1.BN(1_000_000);
/**
* @name BN_BILLION
* @summary BN constant for 1,000,000,000.
*/
exports.BN_BILLION = new bn_js_1.BN(1_000_000_000);
/**
* @name BN_QUINTILL
* @summary BN constant for 1,000,000,000,000,000,000.
*/
exports.BN_QUINTILL = exports.BN_BILLION.mul(exports.BN_BILLION);
/**
* @name BN_MAX_INTEGER
* @summary BN constant for MAX_SAFE_INTEGER
*/
exports.BN_MAX_INTEGER = new bn_js_1.BN(Number.MAX_SAFE_INTEGER);
/**
* @name BN_SQRT_MAX_INTEGER
* @summary BN constant for Math.sqrt(MAX_SAFE_INTEGER)
*/
exports.BN_SQRT_MAX_INTEGER = new bn_js_1.BN(94906265);
+1
View File
@@ -0,0 +1 @@
export { hexToBn as bnFromHex } from '../hex/toBn.js';
+5
View File
@@ -0,0 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.bnFromHex = void 0;
var toBn_js_1 = require("../hex/toBn.js");
Object.defineProperty(exports, "bnFromHex", { enumerable: true, get: function () { return toBn_js_1.hexToBn; } });
+11
View File
@@ -0,0 +1,11 @@
/**
* @summary Utility methods to convert to and from `BN` objects
*/
export { BN } from './bn.js';
export { bnFromHex } from './fromHex.js';
export { bnMax, bnMin } from './min.js';
export { bnSqrt } from './sqrt.js';
export { bnToBn } from './toBn.js';
export { bnToHex } from './toHex.js';
export { bnToU8a } from './toU8a.js';
export * from './consts.js';
+23
View File
@@ -0,0 +1,23 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.bnToU8a = exports.bnToHex = exports.bnToBn = exports.bnSqrt = exports.bnMin = exports.bnMax = exports.bnFromHex = exports.BN = void 0;
const tslib_1 = require("tslib");
/**
* @summary Utility methods to convert to and from `BN` objects
*/
var bn_js_1 = require("./bn.js");
Object.defineProperty(exports, "BN", { enumerable: true, get: function () { return bn_js_1.BN; } });
var fromHex_js_1 = require("./fromHex.js");
Object.defineProperty(exports, "bnFromHex", { enumerable: true, get: function () { return fromHex_js_1.bnFromHex; } });
var min_js_1 = require("./min.js");
Object.defineProperty(exports, "bnMax", { enumerable: true, get: function () { return min_js_1.bnMax; } });
Object.defineProperty(exports, "bnMin", { enumerable: true, get: function () { return min_js_1.bnMin; } });
var sqrt_js_1 = require("./sqrt.js");
Object.defineProperty(exports, "bnSqrt", { enumerable: true, get: function () { return sqrt_js_1.bnSqrt; } });
var toBn_js_1 = require("./toBn.js");
Object.defineProperty(exports, "bnToBn", { enumerable: true, get: function () { return toBn_js_1.bnToBn; } });
var toHex_js_1 = require("./toHex.js");
Object.defineProperty(exports, "bnToHex", { enumerable: true, get: function () { return toHex_js_1.bnToHex; } });
var toU8a_js_1 = require("./toU8a.js");
Object.defineProperty(exports, "bnToU8a", { enumerable: true, get: function () { return toU8a_js_1.bnToU8a; } });
tslib_1.__exportStar(require("./consts.js"), exports);
+29
View File
@@ -0,0 +1,29 @@
import type { BN } from './bn.js';
/**
* @name bnMax
* @summary Finds and returns the highest value in an array of BNs.
* @example
* <BR>
*
* ```javascript
* import BN from 'bn.js';
* import { bnMax } from '@pezkuwi/util';
*
* bnMax([new BN(1), new BN(3), new BN(2)]).toString(); // => '3'
* ```
*/
export declare const bnMax: (...items: BN[]) => BN;
/**
* @name bnMin
* @summary Finds and returns the smallest value in an array of BNs.
* @example
* <BR>
*
* ```javascript
* import BN from 'bn.js';
* import { bnMin } from '@pezkuwi/util';
*
* bnMin([new BN(1), new BN(3), new BN(2)]).toString(); // => '1'
* ```
*/
export declare const bnMin: (...items: BN[]) => BN;
+32
View File
@@ -0,0 +1,32 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.bnMin = exports.bnMax = void 0;
const helpers_js_1 = require("../bi/helpers.js");
/**
* @name bnMax
* @summary Finds and returns the highest value in an array of BNs.
* @example
* <BR>
*
* ```javascript
* import BN from 'bn.js';
* import { bnMax } from '@pezkuwi/util';
*
* bnMax([new BN(1), new BN(3), new BN(2)]).toString(); // => '3'
* ```
*/
exports.bnMax = (0, helpers_js_1.createCmp)((a, b) => a.gt(b));
/**
* @name bnMin
* @summary Finds and returns the smallest value in an array of BNs.
* @example
* <BR>
*
* ```javascript
* import BN from 'bn.js';
* import { bnMin } from '@pezkuwi/util';
*
* bnMin([new BN(1), new BN(3), new BN(2)]).toString(); // => '1'
* ```
*/
exports.bnMin = (0, helpers_js_1.createCmp)((a, b) => a.lt(b));
+16
View File
@@ -0,0 +1,16 @@
import type { ToBn } from '../types.js';
import { BN } from './bn.js';
/**
* @name bnSqrt
* @summary Calculates the integer square root of a BN
* @example
* <BR>
*
* ```javascript
* import BN from 'bn.js';
* import { bnSqrt } from '@pezkuwi/util';
*
* bnSqrt(new BN(16)).toString(); // => '4'
* ```
*/
export declare function bnSqrt<ExtToBn extends ToBn>(value: ExtToBn | BN | bigint | string | number | null): BN;
+41
View File
@@ -0,0 +1,41 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.bnSqrt = bnSqrt;
const bn_js_1 = require("./bn.js");
const consts_js_1 = require("./consts.js");
const toBn_js_1 = require("./toBn.js");
/**
* @name bnSqrt
* @summary Calculates the integer square root of a BN
* @example
* <BR>
*
* ```javascript
* import BN from 'bn.js';
* import { bnSqrt } from '@pezkuwi/util';
*
* bnSqrt(new BN(16)).toString(); // => '4'
* ```
*/
function bnSqrt(value) {
const n = (0, toBn_js_1.bnToBn)(value);
if (n.isNeg()) {
throw new Error('square root of negative numbers is not supported');
}
// https://stackoverflow.com/questions/53683995/javascript-big-integer-square-root/
// shortcut <= 2^53 - 1 to use the JS utils
if (n.lte(consts_js_1.BN_MAX_INTEGER)) {
// ~~ More performant version of Math.floor
return new bn_js_1.BN(~~Math.sqrt(n.toNumber()));
}
// Use sqrt(MAX_SAFE_INTEGER) as starting point. since we already know the
// output will be larger than this, we expect this to be a safe start
let x0 = consts_js_1.BN_SQRT_MAX_INTEGER.clone();
while (true) {
const x1 = n.div(x0).iadd(x0).ishrn(1);
if (x0.eq(x1) || x0.eq(x1.sub(consts_js_1.BN_ONE))) {
return x0;
}
x0 = x1;
}
}
+19
View File
@@ -0,0 +1,19 @@
import type { ToBigInt, ToBn } from '../types.js';
import { BN } from './bn.js';
/**
* @name bnToBn
* @summary Creates a BN value from a BN, bigint, string (base 10 or hex) or number input.
* @description
* `null` inputs returns a `0x0` result, BN values returns the value, numbers returns a BN representation.
* @example
* <BR>
*
* ```javascript
* import BN from 'bn.js';
* import { bnToBn } from '@pezkuwi/util';
*
* bnToBn(0x1234); // => BN(0x1234)
* bnToBn(new BN(0x1234)); // => BN(0x1234)
* ```
*/
export declare function bnToBn<ExtToBn extends ToBigInt | ToBn>(value?: ExtToBn | BN | bigint | string | number | null): BN;
+40
View File
@@ -0,0 +1,40 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.bnToBn = bnToBn;
const toBn_js_1 = require("../hex/toBn.js");
const bigInt_js_1 = require("../is/bigInt.js");
const hex_js_1 = require("../is/hex.js");
const toBigInt_js_1 = require("../is/toBigInt.js");
const toBn_js_2 = require("../is/toBn.js");
const bn_js_1 = require("./bn.js");
/**
* @name bnToBn
* @summary Creates a BN value from a BN, bigint, string (base 10 or hex) or number input.
* @description
* `null` inputs returns a `0x0` result, BN values returns the value, numbers returns a BN representation.
* @example
* <BR>
*
* ```javascript
* import BN from 'bn.js';
* import { bnToBn } from '@pezkuwi/util';
*
* bnToBn(0x1234); // => BN(0x1234)
* bnToBn(new BN(0x1234)); // => BN(0x1234)
* ```
*/
function bnToBn(value) {
return value
? bn_js_1.BN.isBN(value)
? value
: (0, hex_js_1.isHex)(value)
? (0, toBn_js_1.hexToBn)(value.toString())
: (0, bigInt_js_1.isBigInt)(value)
? new bn_js_1.BN(value.toString())
: (0, toBn_js_2.isToBn)(value)
? value.toBn()
: (0, toBigInt_js_1.isToBigInt)(value)
? new bn_js_1.BN(value.toBigInt().toString())
: new bn_js_1.BN(value)
: new bn_js_1.BN(0);
}
+18
View File
@@ -0,0 +1,18 @@
import type { HexString, NumberOptions, ToBn } from '../types.js';
import type { BN } from './bn.js';
/**
* @name bnToHex
* @summary Creates a hex value from a BN.js bignumber object.
* @description
* `null` inputs returns a `0x` result, BN values return the actual value as a `0x` prefixed hex value. Anything that is not a BN object throws an error. With `bitLength` set, it fixes the number to the specified length.
* @example
* <BR>
*
* ```javascript
* import BN from 'bn.js';
* import { bnToHex } from '@pezkuwi/util';
*
* bnToHex(new BN(0x123456)); // => '0x123456'
* ```
*/
export declare function bnToHex<ExtToBn extends ToBn>(value?: ExtToBn | BN | bigint | number | null, { bitLength, isLe, isNegative }?: NumberOptions): HexString;
+23
View File
@@ -0,0 +1,23 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.bnToHex = bnToHex;
const index_js_1 = require("../u8a/index.js");
const toU8a_js_1 = require("./toU8a.js");
/**
* @name bnToHex
* @summary Creates a hex value from a BN.js bignumber object.
* @description
* `null` inputs returns a `0x` result, BN values return the actual value as a `0x` prefixed hex value. Anything that is not a BN object throws an error. With `bitLength` set, it fixes the number to the specified length.
* @example
* <BR>
*
* ```javascript
* import BN from 'bn.js';
* import { bnToHex } from '@pezkuwi/util';
*
* bnToHex(new BN(0x123456)); // => '0x123456'
* ```
*/
function bnToHex(value, { bitLength = -1, isLe = false, isNegative = false } = {}) {
return (0, index_js_1.u8aToHex)((0, toU8a_js_1.bnToU8a)(value, { bitLength, isLe, isNegative }));
}
+17
View File
@@ -0,0 +1,17 @@
import type { NumberOptions, ToBn } from '../types.js';
import type { BN } from './bn.js';
/**
* @name bnToU8a
* @summary Creates a Uint8Array object from a BN.
* @description
* `null`/`undefined`/`NaN` inputs returns an empty `Uint8Array` result. `BN` input values return the actual bytes value converted to a `Uint8Array`. Optionally convert using little-endian format if `isLE` is set.
* @example
* <BR>
*
* ```javascript
* import { bnToU8a } from '@pezkuwi/util';
*
* bnToU8a(new BN(0x1234)); // => [0x12, 0x34]
* ```
*/
export declare function bnToU8a<ExtToBn extends ToBn>(value?: ExtToBn | BN | bigint | number | null, { bitLength, isLe, isNegative }?: NumberOptions): Uint8Array;
+36
View File
@@ -0,0 +1,36 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.bnToU8a = bnToU8a;
const toBn_js_1 = require("./toBn.js");
const DEFAULT_OPTS = { bitLength: -1, isLe: true, isNegative: false };
/**
* @name bnToU8a
* @summary Creates a Uint8Array object from a BN.
* @description
* `null`/`undefined`/`NaN` inputs returns an empty `Uint8Array` result. `BN` input values return the actual bytes value converted to a `Uint8Array`. Optionally convert using little-endian format if `isLE` is set.
* @example
* <BR>
*
* ```javascript
* import { bnToU8a } from '@pezkuwi/util';
*
* bnToU8a(new BN(0x1234)); // => [0x12, 0x34]
* ```
*/
function bnToU8a(value, { bitLength = -1, isLe = true, isNegative = false } = DEFAULT_OPTS) {
const valueBn = (0, toBn_js_1.bnToBn)(value);
const byteLength = bitLength === -1
? Math.ceil(valueBn.bitLength() / 8)
: Math.ceil((bitLength || 0) / 8);
if (!value) {
return bitLength === -1
? new Uint8Array(1)
: new Uint8Array(byteLength);
}
const output = new Uint8Array(byteLength);
const bn = isNegative
? valueBn.toTwos(byteLength * 8)
: valueBn;
output.set(bn.toArray(isLe ? 'le' : 'be', byteLength), 0);
return output;
}