Adjust for anon (#1269)

This commit is contained in:
Jaco
2021-12-01 16:19:50 +02:00
committed by GitHub
parent 39e6a3c048
commit 50317d7dc3
2 changed files with 10 additions and 7 deletions
+5 -5
View File
@@ -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
+5 -2
View File
@@ -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);