Skip to content

Commit 742b8dc

Browse files
authored
fix: fix util.global (#1441)
1 parent f2faa8c commit 742b8dc

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/util/minimal.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ util.pool = require("@protobufjs/pool");
2626
util.LongBits = require("./longbits");
2727

2828
// global object reference
29-
util.global = typeof window !== "undefined" && window
30-
|| typeof global !== "undefined" && global
29+
util.global = typeof global !== "undefined" && Object.prototype.toString.call(global) === "[object global]" && global
30+
|| typeof window !== "undefined" && window
3131
|| typeof self !== "undefined" && self
3232
|| this; // eslint-disable-line no-invalid-this
3333

@@ -52,9 +52,7 @@ util.emptyObject = Object.freeze ? Object.freeze({}) : /* istanbul ignore next *
5252
* @type {boolean}
5353
* @const
5454
*/
55-
util.isNode = Boolean(typeof process !== "undefined" && process &&
56-
typeof process.versions !== "undefined" && process.versions &&
57-
process.versions.node);
55+
util.isNode = Boolean(util.global.process && util.global.process.versions && util.global.process.versions.node);
5856

5957
/**
6058
* Tests if the specified value is an integer.

0 commit comments

Comments
 (0)