mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-02 16:17:50 +00:00
Simplify umd and exports.
This commit is contained in:
46
lodash.js
46
lodash.js
@@ -328,12 +328,6 @@
|
||||
'`': '`'
|
||||
};
|
||||
|
||||
/** Used to determine if values are of the language type `Object`. */
|
||||
var objectTypes = {
|
||||
'function': true,
|
||||
'object': true
|
||||
};
|
||||
|
||||
/** Used to escape characters for inclusion in compiled string literals. */
|
||||
var stringEscapes = {
|
||||
'\\': '\\',
|
||||
@@ -349,41 +343,25 @@
|
||||
freeParseInt = parseInt;
|
||||
|
||||
/** Detect free variable `exports`. */
|
||||
var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType)
|
||||
? exports
|
||||
: undefined;
|
||||
var freeExports = typeof exports == 'object' && exports;
|
||||
|
||||
/** Detect free variable `module`. */
|
||||
var freeModule = (objectTypes[typeof module] && module && !module.nodeType)
|
||||
? module
|
||||
: undefined;
|
||||
var freeModule = freeExports && typeof module == 'object' && module;
|
||||
|
||||
/** Detect the popular CommonJS extension `module.exports`. */
|
||||
var moduleExports = (freeModule && freeModule.exports === freeExports)
|
||||
? freeExports
|
||||
: undefined;
|
||||
var moduleExports = freeModule && freeModule.exports === freeExports;
|
||||
|
||||
/** Detect free variable `global` from Node.js. */
|
||||
var freeGlobal = checkGlobal(freeExports && freeModule && typeof global == 'object' && global);
|
||||
var freeGlobal = checkGlobal(typeof global == 'object' && global);
|
||||
|
||||
/** Detect free variable `self`. */
|
||||
var freeSelf = checkGlobal(objectTypes[typeof self] && self);
|
||||
|
||||
/** Detect free variable `window`. */
|
||||
var freeWindow = checkGlobal(objectTypes[typeof window] && window);
|
||||
var freeSelf = checkGlobal(typeof self == 'object' && self);
|
||||
|
||||
/** Detect `this` as the global object. */
|
||||
var thisGlobal = checkGlobal(objectTypes[typeof this] && this);
|
||||
var thisGlobal = checkGlobal(typeof this == 'object' && this);
|
||||
|
||||
/**
|
||||
* Used as a reference to the global object.
|
||||
*
|
||||
* The `this` value is used if it's the global object to avoid Greasemonkey's
|
||||
* restricted `window` object, otherwise the `window` object is used.
|
||||
*/
|
||||
var root = freeGlobal ||
|
||||
((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) ||
|
||||
freeSelf || thisGlobal || Function('return this')();
|
||||
/** Used as a reference to the global object. */
|
||||
var root = freeGlobal || freeSelf || thisGlobal || Function('return this')();
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
@@ -16321,7 +16299,7 @@
|
||||
// also prevents errors in cases where Lodash is loaded by a script tag in the
|
||||
// presence of an AMD loader. See http://requirejs.org/docs/errors.html#mismatch
|
||||
// for more details. Use `_.noConflict` to remove Lodash from the global object.
|
||||
(freeWindow || freeSelf || {})._ = _;
|
||||
(freeSelf || {})._ = _;
|
||||
|
||||
// Some AMD build optimizers like r.js check for condition patterns like the following:
|
||||
if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
|
||||
@@ -16332,11 +16310,9 @@
|
||||
});
|
||||
}
|
||||
// Check for `exports` after `define` in case a build optimizer adds an `exports` object.
|
||||
else if (freeExports && freeModule) {
|
||||
else if (freeModule) {
|
||||
// Export for Node.js.
|
||||
if (moduleExports) {
|
||||
(freeModule.exports = _)._ = _;
|
||||
}
|
||||
(freeModule.exports = _)._ = _;
|
||||
// Export for CommonJS support.
|
||||
freeExports._ = _;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user