Adjust for anon (#1269)
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
// Copyright 2017-2021 @polkadot/util authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
type NewBigInt = (value: string | number | bigint | boolean) => bigint;
|
||||
|
||||
/**
|
||||
* @name _n
|
||||
* @description Creates a new instance of BigInt in environments that do support it
|
||||
*/
|
||||
export const _n: NewBigInt = typeof BigInt !== 'undefined'
|
||||
? (n: string | number | bigint | boolean) => BigInt(n)
|
||||
: () => Number.NaN as unknown as bigint;
|
||||
export function _n (n: string | number | bigint | boolean): bigint {
|
||||
return typeof BigInt === 'function'
|
||||
? BigInt(n)
|
||||
: Number.NaN as unknown as bigint;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name _0n
|
||||
|
||||
@@ -6,8 +6,11 @@ export type TypedArray = Int8Array | Uint8ClampedArray | Uint8Array |
|
||||
Uint16Array | Int16Array | Uint32Array | Int32Array;
|
||||
|
||||
// helper to protect against older bundlers
|
||||
export const _n: (value: string | number | bigint | boolean) => bigint =
|
||||
typeof BigInt !== 'undefined' ? (n: string | number | bigint | boolean) => BigInt(n) : () => Number.NaN as unknown as bigint;
|
||||
export function _n (n: string | number | bigint | boolean): bigint {
|
||||
return typeof BigInt === 'function'
|
||||
? BigInt(n)
|
||||
: Number.NaN as unknown as bigint;
|
||||
}
|
||||
|
||||
// Cast array to different type
|
||||
export const u8 = (arr: TypedArray) => new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);
|
||||
|
||||
Reference in New Issue
Block a user