Skip to content

Commit

Permalink
reorder
Browse files Browse the repository at this point in the history
  • Loading branch information
dcodeIO committed Jul 14, 2020
1 parent 8f5e73b commit bde8f34
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
9 changes: 6 additions & 3 deletions index.d.ts
Expand Up @@ -1951,15 +1951,18 @@ export namespace util {
public length(): number;
}

/** Whether running within node or not. */
let isNode: boolean;

/** Global object reference. */
let global: object;

/** An immuable empty array. */
const emptyArray: any[];

/** An immutable empty object. */
const emptyObject: object;

/** Whether running within node or not. */
const isNode: boolean;

/**
* Tests if the specified value is an integer.
* @param value Value to test
Expand Down
35 changes: 16 additions & 19 deletions src/util/minimal.js
Expand Up @@ -25,18 +25,23 @@ util.pool = require("@protobufjs/pool");
// utility to work with the low and high bits of a 64 bit value
util.LongBits = require("./longbits");

/** Tests whether the specified object is most likely a node.js process. */
function isNodeProcess(process) {
return Boolean(process && process.versions && process.versions.node);
}

/** Tests whether the specified object is most likely a node.js global. */
function isNodeGlobal(global) {
return global && isNodeProcess(global.process);
}
/**
* Whether running within node or not.
* @memberof util
* @type {boolean}
*/
util.isNode = typeof global !== "undefined"
&& global
&& global.process
&& global.process.versions
&& global.process.versions.node;

// global object reference
util.global = typeof global !== "undefined" && isNodeGlobal(global) && global
/**
* Global object reference.
* @memberof util
* @type {Object}
*/
util.global = util.isNode && global
|| typeof window !== "undefined" && window
|| typeof self !== "undefined" && self
|| this; // eslint-disable-line no-invalid-this
Expand All @@ -56,14 +61,6 @@ util.emptyArray = Object.freeze ? Object.freeze([]) : /* istanbul ignore next */
*/
util.emptyObject = Object.freeze ? Object.freeze({}) : /* istanbul ignore next */ {}; // used on prototypes

/**
* Whether running within node or not.
* @memberof util
* @type {boolean}
* @const
*/
util.isNode = isNodeProcess(util.global.process);

/**
* Tests if the specified value is an integer.
* @function
Expand Down

0 comments on commit bde8f34

Please sign in to comment.