Skip to content

Commit

Permalink
Simplify the root assignment.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton committed Mar 5, 2015
1 parent 1e647a2 commit d898fce
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions lodash.src.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,30 +259,29 @@
'\u2029': 'u2029'
};

/**
* Used as a reference to the global object.
*
* The `this` value is used if it is the global object to avoid Greasemonkey's
* restricted `window` object, otherwise the `window` object is used.
*/
var root = (objectTypes[typeof window] && window !== (this && this.window)) ? window : this;

/** Detect free variable `exports`. */
var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports;

/** Detect free variable `module`. */
var freeModule = objectTypes[typeof module] && module && !module.nodeType && module;

/** Detect free variable `global` from Node.js or Browserified code and use it as `root`. */
/** Detect free variable `global` from Node.js. */
var freeGlobal = freeExports && freeModule && typeof global == 'object' && global;
if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal ||
(typeof freeGlobal.WorkerGlobalScope == 'function' && freeGlobal instanceof freeGlobal.WorkerGlobalScope))) {
root = freeGlobal;
}

/** Detect free variable `window`. */
var freeWindow = objectTypes[typeof window] && window;

/** Detect the popular CommonJS extension `module.exports`. */
var moduleExports = freeModule && freeModule.exports === freeExports && freeExports;

/**
* Used as a reference to the global object.
*
* The `this` value is used if it is the global object to avoid Greasemonkey's
* restricted `window` object, otherwise the `window` object is used.
*/
var root = freeGlobal || ((freeWindow !== (this && this.window)) && freeWindow) || this;

/*--------------------------------------------------------------------------*/

/**
Expand Down

0 comments on commit d898fce

Please sign in to comment.