From 742b8dcbc750f9c2659088cbd88ea61fd11b24a7 Mon Sep 17 00:00:00 2001 From: Daniel Wirtz Date: Tue, 14 Jul 2020 00:57:03 +0200 Subject: [PATCH] fix: fix util.global (#1441) --- src/util/minimal.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/util/minimal.js b/src/util/minimal.js index 559aac7c9..e384b62fb 100644 --- a/src/util/minimal.js +++ b/src/util/minimal.js @@ -26,8 +26,8 @@ util.pool = require("@protobufjs/pool"); util.LongBits = require("./longbits"); // global object reference -util.global = typeof window !== "undefined" && window - || typeof global !== "undefined" && global +util.global = typeof global !== "undefined" && Object.prototype.toString.call(global) === "[object global]" && global + || typeof window !== "undefined" && window || typeof self !== "undefined" && self || this; // eslint-disable-line no-invalid-this @@ -52,9 +52,7 @@ util.emptyObject = Object.freeze ? Object.freeze({}) : /* istanbul ignore next * * @type {boolean} * @const */ -util.isNode = Boolean(typeof process !== "undefined" && process && - typeof process.versions !== "undefined" && process.versions && - process.versions.node); +util.isNode = Boolean(util.global.process && util.global.process.versions && util.global.process.versions.node); /** * Tests if the specified value is an integer.