mirror of
https://github.com/pezkuwichain/pezkuwi-common.git
synced 2026-11-13 02:07:07 +00:00
The header rule takes the current year as the end of the range, as upstream's does; 581 sources still ended at 2025, which failed lint. Lint never ran to completion here, so this went unseen. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
34 lines
1.0 KiB
TypeScript
34 lines
1.0 KiB
TypeScript
// Copyright 2017-2026 @pezkuwi/util authors & contributors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import type { BN } from '../bn/bn.js';
|
|
import type { ToBigInt, ToBn } from '../types.js';
|
|
|
|
import { BigInt } from '@pezkuwi/x-bigint';
|
|
|
|
import { hexToBigInt } from '../hex/toBigInt.js';
|
|
import { isBn } from '../is/bn.js';
|
|
import { isHex } from '../is/hex.js';
|
|
import { isToBigInt } from '../is/toBigInt.js';
|
|
import { isToBn } from '../is/toBn.js';
|
|
|
|
/**
|
|
* @name nToBigInt
|
|
* @summary Creates a bigInt value from a BN, bigint, string (base 10 or hex) or number input.
|
|
*/
|
|
export function nToBigInt <ExtToBn extends ToBigInt | ToBn> (value?: ExtToBn | BN | bigint | string | number | null): bigint {
|
|
return typeof value === 'bigint'
|
|
? value
|
|
: !value
|
|
? BigInt(0)
|
|
: isHex(value)
|
|
? hexToBigInt(value.toString())
|
|
: isBn(value)
|
|
? BigInt(value.toString())
|
|
: isToBigInt(value)
|
|
? value.toBigInt()
|
|
: isToBn(value)
|
|
? BigInt(value.toBn().toString())
|
|
: BigInt(value);
|
|
}
|