diff --git a/lib/prelude.js b/lib/prelude.js index 6376711a4..653a38d7a 100644 --- a/lib/prelude.js +++ b/lib/prelude.js @@ -13,7 +13,10 @@ } // Expose globally - var protobuf = global.protobuf = $require(entries[0]); + var protobuf = $require(entries[0]); + if (typeof global !== "undefined") { + global.protobuf = protobuf; + } // Be nice to AMD if (typeof define === "function" && define.amd) diff --git a/src/util/minimal.js b/src/util/minimal.js index e15a37251..c240308a2 100644 --- a/src/util/minimal.js +++ b/src/util/minimal.js @@ -46,7 +46,7 @@ util.emptyObject = Object.freeze ? Object.freeze({}) : /* istanbul ignore next * * @type {boolean} * @const */ -util.isNode = Boolean(global.process && global.process.versions && global.process.versions.node); +util.isNode = Boolean(typeof global !== "undefined" && global.process && global.process.versions && global.process.versions.node); /** * Tests if the specified value is an integer. @@ -164,7 +164,7 @@ util.Array = typeof Uint8Array !== "undefined" ? Uint8Array /* istanbul ignore n * Long.js's Long class if available. * @type {Constructor} */ -util.Long = /* istanbul ignore next */ global.dcodeIO && /* istanbul ignore next */ global.dcodeIO.Long || util.inquire("long"); +util.Long = /* istanbul ignore next */ typeof global !== "undefined" && /* istanbul ignore next */ global.dcodeIO && /* istanbul ignore next */ global.dcodeIO.Long || util.inquire("long"); /** * Regular expression used to verify 2 bit (`bool`) map keys.