From 05a55d694d5c871251612957180a6a9a8c410846 Mon Sep 17 00:00:00 2001 From: Constantine Peresypkin Date: Thu, 9 Jul 2020 18:50:47 +0300 Subject: [PATCH] fix globals: global, process both globals may not be available in embedded environments there is no need to call `process` at all if it's not there there is a standardized `global` object now: [globalThis](https://github.com/tc39/proposal-global), it should be used as the last resort --- src/core/browserfs.ts | 2 +- src/core/global.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/browserfs.ts b/src/core/browserfs.ts index 3d3092fc..94906b90 100644 --- a/src/core/browserfs.ts +++ b/src/core/browserfs.ts @@ -13,7 +13,7 @@ import * as BFSUtils from './util'; import * as Errors from './api_error'; import setImmediate from '../generic/setImmediate'; -if (( process)['initializeTTYs']) { +if (process && ( process)['initializeTTYs']) { ( process)['initializeTTYs'](); } diff --git a/src/core/global.ts b/src/core/global.ts index b14ec46f..7e947a13 100644 --- a/src/core/global.ts +++ b/src/core/global.ts @@ -6,9 +6,9 @@ * @hidden * @private */ -declare var global: any; +declare var globalThis: any; /** * @hidden */ -const toExport: any = typeof(window) !== 'undefined' ? window : typeof(self) !== 'undefined' ? self : global; +const toExport: any = typeof(window) !== 'undefined' ? window : typeof(self) !== 'undefined' ? self : typeof (global) !== "undefined" ? global : globalThis; export default toExport;