Formatting cleanups for nested conditionals (#902)
* Formatting cleanups for nested conditionals * Transports
This commit is contained in:
@@ -6,7 +6,7 @@ import type { TransportDef } from './types';
|
||||
|
||||
import LedgerWebUSB from '@ledgerhq/hw-transport-webusb';
|
||||
|
||||
const transports: TransportDef[] = [
|
||||
export const transports: TransportDef[] = [
|
||||
// deprecated
|
||||
// import LedgerU2F from '@ledgerhq/hw-transport-u2f';
|
||||
// {
|
||||
@@ -20,5 +20,3 @@ const transports: TransportDef[] = [
|
||||
type: 'webusb'
|
||||
}
|
||||
];
|
||||
|
||||
export { transports };
|
||||
|
||||
@@ -6,12 +6,10 @@ import type { TransportDef } from './types';
|
||||
|
||||
import LedgerHid from '@ledgerhq/hw-transport-node-hid-singleton';
|
||||
|
||||
const transports: TransportDef[] = [
|
||||
export const transports: TransportDef[] = [
|
||||
{
|
||||
create: (): Promise<Transport> =>
|
||||
LedgerHid.create(),
|
||||
type: 'hid'
|
||||
}
|
||||
];
|
||||
|
||||
export { transports };
|
||||
|
||||
@@ -3,6 +3,4 @@
|
||||
|
||||
import type { TransportDef } from './types';
|
||||
|
||||
const transports: TransportDef[] = [];
|
||||
|
||||
export { transports };
|
||||
export const transports: TransportDef[] = [];
|
||||
|
||||
@@ -5,6 +5,8 @@ import nodeFetch from 'node-fetch';
|
||||
|
||||
import { xglobal } from '@polkadot/x-global';
|
||||
|
||||
export const fetch = typeof xglobal.fetch === 'undefined'
|
||||
? nodeFetch as unknown as typeof global.fetch
|
||||
: xglobal.fetch;
|
||||
export const fetch = (
|
||||
typeof xglobal.fetch === 'undefined'
|
||||
? nodeFetch as unknown as typeof global.fetch
|
||||
: xglobal.fetch
|
||||
);
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
// Copyright 2017-2021 @polkadot/x-fetch authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export const xglobal = typeof global !== 'undefined'
|
||||
? global
|
||||
: typeof self !== 'undefined'
|
||||
? self
|
||||
: typeof window !== 'undefined'
|
||||
? window
|
||||
: this as unknown as (Window & typeof globalThis);
|
||||
export const xglobal = (
|
||||
typeof global !== 'undefined'
|
||||
? global
|
||||
: typeof self !== 'undefined'
|
||||
? self
|
||||
: typeof window !== 'undefined'
|
||||
? window
|
||||
: this as unknown as (Window & typeof globalThis)
|
||||
);
|
||||
|
||||
@@ -31,9 +31,11 @@ function getRandomValuesGlobal <T extends Uint8Array> (arr: T): T {
|
||||
return crypto.getRandomValues(arr);
|
||||
}
|
||||
|
||||
export const getRandomValues = typeof xglobal.crypto === 'object' && typeof xglobal.crypto.getRandomValues === 'function'
|
||||
? getRandomValuesGlobal
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-explicit-any
|
||||
: (typeof (xglobal as any).nativeCallSyncHook === 'undefined' || !NativeModules.ExpoRandom)
|
||||
? insecureRandomValues
|
||||
: getRandomValuesNative;
|
||||
export const getRandomValues = (
|
||||
typeof xglobal.crypto === 'object' && typeof xglobal.crypto.getRandomValues === 'function'
|
||||
? getRandomValuesGlobal
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-explicit-any
|
||||
: (typeof (xglobal as any).nativeCallSyncHook === 'undefined' || !NativeModules.ExpoRandom)
|
||||
? insecureRandomValues
|
||||
: getRandomValuesNative
|
||||
);
|
||||
|
||||
@@ -5,6 +5,8 @@ import { xglobal } from '@polkadot/x-global';
|
||||
|
||||
import { TextDecoder as Fallback } from './fallback';
|
||||
|
||||
export const TextDecoder = typeof xglobal.TextDecoder === 'undefined'
|
||||
? Fallback as unknown as typeof xglobal.TextDecoder
|
||||
: xglobal.TextDecoder;
|
||||
export const TextDecoder = (
|
||||
typeof xglobal.TextDecoder === 'undefined'
|
||||
? Fallback as unknown as typeof xglobal.TextDecoder
|
||||
: xglobal.TextDecoder
|
||||
);
|
||||
|
||||
@@ -5,6 +5,8 @@ import util from 'util';
|
||||
|
||||
import { xglobal } from '@polkadot/x-global';
|
||||
|
||||
export const TextDecoder = typeof xglobal.TextDecoder === 'undefined'
|
||||
? util.TextDecoder as unknown as typeof xglobal.TextDecoder
|
||||
: xglobal.TextDecoder;
|
||||
export const TextDecoder = (
|
||||
typeof xglobal.TextDecoder === 'undefined'
|
||||
? util.TextDecoder as unknown as typeof xglobal.TextDecoder
|
||||
: xglobal.TextDecoder
|
||||
);
|
||||
|
||||
@@ -5,6 +5,8 @@ import { xglobal } from '@polkadot/x-global';
|
||||
|
||||
import { TextEncoder as Fallback } from './fallback';
|
||||
|
||||
export const TextEncoder = typeof xglobal.TextEncoder === 'undefined'
|
||||
? Fallback as unknown as typeof xglobal.TextEncoder
|
||||
: xglobal.TextEncoder;
|
||||
export const TextEncoder = (
|
||||
typeof xglobal.TextEncoder === 'undefined'
|
||||
? Fallback as unknown as typeof xglobal.TextEncoder
|
||||
: xglobal.TextEncoder
|
||||
);
|
||||
|
||||
@@ -20,6 +20,8 @@ class NodeFallback {
|
||||
}
|
||||
}
|
||||
|
||||
export const TextEncoder = typeof xglobal.TextEncoder === 'undefined'
|
||||
? NodeFallback as unknown as typeof xglobal.TextEncoder
|
||||
: xglobal.TextEncoder;
|
||||
export const TextEncoder = (
|
||||
typeof xglobal.TextEncoder === 'undefined'
|
||||
? NodeFallback as unknown as typeof xglobal.TextEncoder
|
||||
: xglobal.TextEncoder
|
||||
);
|
||||
|
||||
@@ -5,6 +5,8 @@ import ws from 'websocket';
|
||||
|
||||
import { xglobal } from '@polkadot/x-global';
|
||||
|
||||
export const WebSocket = typeof xglobal.WebSocket === 'undefined'
|
||||
? ws.w3cwebsocket as unknown as typeof xglobal.WebSocket
|
||||
: xglobal.WebSocket;
|
||||
export const WebSocket = (
|
||||
typeof xglobal.WebSocket === 'undefined'
|
||||
? ws.w3cwebsocket as unknown as typeof xglobal.WebSocket
|
||||
: xglobal.WebSocket
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user