Bump dev (w/ ts-eslint updates) (#1854)

* Bump dev (w/ ts-eslint updates)

* Adjust ipfs compat check
This commit is contained in:
Jaco
2023-07-15 09:57:35 +03:00
committed by GitHub
parent d407513dd1
commit 41caf2fd6d
68 changed files with 248 additions and 228 deletions
+2 -2
View File
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
import type { BN } from '../bn/bn.js';
import type { HexString, ToBigInt, ToBn } from '../types.js';
import type { ToBigInt, ToBn } from '../types.js';
import { BigInt } from '@polkadot/x-bigint';
@@ -16,7 +16,7 @@ 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?: HexString | ExtToBn | BN | bigint | string | number | null): bigint {
export function nToBigInt <ExtToBn extends ToBigInt | ToBn> (value?: ExtToBn | BN | bigint | string | number | null): bigint {
return typeof value === 'bigint'
? value
: !value
+2 -2
View File
@@ -1,7 +1,7 @@
// Copyright 2017-2023 @polkadot/util authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { HexString, ToBigInt, ToBn } from '../types.js';
import type { ToBigInt, ToBn } from '../types.js';
import { hexToBn } from '../hex/toBn.js';
import { isBigInt } from '../is/bigInt.js';
@@ -26,7 +26,7 @@ import { BN } from './bn.js';
* bnToBn(new BN(0x1234)); // => BN(0x1234)
* ```
*/
export function bnToBn <ExtToBn extends ToBigInt | ToBn> (value?: HexString | ExtToBn | BN | bigint | string | number | null): BN {
export function bnToBn <ExtToBn extends ToBigInt | ToBn> (value?: ExtToBn | BN | bigint | string | number | null): BN {
return value
? BN.isBN(value)
? value
+1 -1
View File
@@ -24,7 +24,7 @@ function formatValue (elapsed: number): string {
* @description Formats an elapsed value into s, m, h or day segments
*/
export function formatElapsed <ExtToBn extends ToBn> (now?: Date | null, value?: bigint | BN | ExtToBn | Date | number | null): string {
const tsNow = (now && now.getTime()) || 0;
const tsNow = now?.getTime() || 0;
const tsValue = value instanceof Date
? value.getTime()
: bnToBn(value).toNumber();
+1 -3
View File
@@ -1,8 +1,6 @@
// Copyright 2017-2023 @polkadot/util authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { HexString } from '../types.js';
const CHR = '0123456789abcdef';
const U8 = new Uint8Array(256);
const U16 = new Uint8Array(256 * 256);
@@ -38,7 +36,7 @@ for (let i = 0; i < 256; i++) {
* hexToU8a('0x80001f', 32); // Uint8Array([0x00, 0x80, 0x00, 0x1f])
* ```
*/
export function hexToU8a (value?: HexString | string | null, bitLength = -1): Uint8Array {
export function hexToU8a (value?: string | null, bitLength = -1): Uint8Array {
if (!value) {
return new Uint8Array();
}
+1 -3
View File
@@ -1,8 +1,6 @@
// Copyright 2017-2023 @polkadot/util authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { HexString } from '../types.js';
/**
* @name hexToU8a
* @summary Creates a Uint8Array object from a hex string.
@@ -18,7 +16,7 @@ import type { HexString } from '../types.js';
* hexToU8a('0x80001f', 32); // Uint8Array([0x00, 0x80, 0x00, 0x1f])
* ```
*/
export function hexToU8a (_value?: HexString | string | null, bitLength = -1): Uint8Array {
export function hexToU8a (_value?: string | null, bitLength = -1): Uint8Array {
if (!_value) {
return new Uint8Array();
}
+1 -1
View File
@@ -5,6 +5,6 @@
* @name isArray
* @summary Tests for a Array instance.
*/
export function isArray <T> (value?: unknown): value is Array<T> {
export function isArray <T> (value?: unknown): value is T[] {
return Array.isArray(value);
}
+2 -4
View File
@@ -3,10 +3,8 @@
import { stringify } from '../stringify.js';
interface ObjectIndexed {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[index: string]: any;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
type ObjectIndexed = Record<string, any>;
/**
* @name isJsonObject
+2 -4
View File
@@ -1,10 +1,8 @@
// Copyright 2017-2023 @polkadot/util authors & contributors
// SPDX-License-Identifier: Apache-2.0
interface ObjectIndexed {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[index: string]: any;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
type ObjectIndexed = Record<string, any>;
/**
* @name isObject
+1 -3
View File
@@ -3,8 +3,6 @@
// Adapted from https://github.com/JulienPalard/is_utf8/blob/master/is_utf8.c
import type { HexString } from '../types.js';
import { u8aToU8a } from '../u8a/toU8a.js';
import { isString } from './string.js';
@@ -14,7 +12,7 @@ import { isString } from './string.js';
* @description
* Checks to see if the input string or Uint8Array is valid Utf8
*/
export function isUtf8 (value?: HexString | number[] | Uint8Array | string | null): boolean {
export function isUtf8 (value?: number[] | Uint8Array | string | null): boolean {
if (!value) {
return isString(value);
}
+1 -1
View File
@@ -3,7 +3,7 @@
type AnyFn = (...args: unknown[]) => unknown;
type WithToString = { toString: () => string };
interface WithToString { toString: () => string }
/**
* @name lazyMethod
+1 -1
View File
@@ -40,7 +40,7 @@ export function memoize <T, F extends (...args: any[]) => T> (fn: F, { getInstan
const stringParams = stringify(args);
const instanceId = getInstanceId();
if (cache[instanceId] && cache[instanceId][stringParams] !== undefined) {
if (cache[instanceId]?.[stringParams] !== undefined) {
delete cache[instanceId][stringParams];
}
};
+1 -1
View File
@@ -34,7 +34,7 @@ describe('objectProperty/objectProperties', (): void => {
b = 1;
get a () {
return 1;
return 1 + 0;
}
}
+1 -1
View File
@@ -90,7 +90,7 @@ export interface BufferObjClass extends Class<BufferObj> {
isBuffer: (value: unknown) => boolean;
}
export type U8aLike = HexString | number[] | Uint8Array | AnyString;
export type U8aLike = number[] | Uint8Array | AnyString;
export interface Observable {
next: (...params: unknown[]) => unknown;
+1 -3
View File
@@ -1,8 +1,6 @@
// Copyright 2017-2023 @polkadot/util authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { HexString } from '../types.js';
import { u8aToU8a } from './toU8a.js';
/**
@@ -21,7 +19,7 @@ import { u8aToU8a } from './toU8a.js';
* u8aCmp(new Uint8Array([0x69, 0x65]), new Uint8Array([0x68, 0x65])); // +1
* ```
*/
export function u8aCmp (a: HexString | Uint8Array | string, b: HexString | Uint8Array | string): number {
export function u8aCmp (a: string | Uint8Array, b: string | Uint8Array): number {
const u8aa = u8aToU8a(a);
const u8ab = u8aToU8a(b);
let i = 0;
+1 -3
View File
@@ -1,8 +1,6 @@
// Copyright 2017-2023 @polkadot/util authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { HexString } from '../types.js';
import { u8aToU8a } from './toU8a.js';
/**
@@ -19,7 +17,7 @@ import { u8aToU8a } from './toU8a.js';
* u8aEq(new Uint8Array([0x68, 0x65]), new Uint8Array([0x68, 0x65])); // true
* ```
*/
export function u8aEq (a: HexString | Uint8Array | string, b: HexString | Uint8Array | string): boolean {
export function u8aEq (a: string | Uint8Array, b: string | Uint8Array): boolean {
const u8aa = u8aToU8a(a);
const u8ab = u8aToU8a(b);
+1 -1
View File
@@ -54,7 +54,7 @@ export function u8aToHex (value?: Uint8Array | null, bitLength = -1, isPrefixed
? '0x'
: '' as HexString;
if (!value || !value.length) {
if (!value?.length) {
return empty;
} else if (bitLength > 0) {
const length = Math.ceil(bitLength / 8);
+1 -1
View File
@@ -21,7 +21,7 @@ export function u8aToHex (value?: Uint8Array | null, bitLength = -1, isPrefixed
const length = Math.ceil(bitLength / 8);
return `${isPrefixed ? '0x' : ''}${
!value || !value.length
!value?.length
? ''
: (bitLength > 0 && value.length > length)
? `${Buffer.from(value.subarray(0, length / 2)).toString('hex')}…${Buffer.from(value.subarray(value.length - length / 2)).toString('hex')}`