Replace process.browser with detect-node library

This commit is contained in:
Fabio Berger
2018-07-13 15:03:13 +02:00
parent 9d24341d94
commit 4c7fd5a4e8
3 changed files with 7 additions and 1 deletions

View File

@@ -39,6 +39,7 @@
"@0xproject/typescript-typings": "^0.4.2",
"@types/node": "^8.0.53",
"bignumber.js": "~4.1.0",
"detect-node": "2.0.3",
"ethereum-types": "^0.0.2",
"ethereumjs-util": "^5.1.1",
"ethers": "3.0.22",

View File

@@ -1,3 +1,4 @@
import isNode = require('detect-node');
import 'isomorphic-fetch';
export const fetchAsync = async (
@@ -6,7 +7,7 @@ export const fetchAsync = async (
timeoutMs: number = 20000,
): Promise<Response> => {
let optionsWithAbortParam;
if ((process as any).browser === true) {
if (isNode) {
const controller = new AbortController();
const signal = controller.signal;
setTimeout(() => {

View File

@@ -4,3 +4,7 @@ declare module '*.json' {
export default json;
/* tslint:enable */
}
declare module 'detect-node' {
export const isNode: boolean;
}