mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 10:07:48 +00:00
Remove defineProperty forks of baseSetData and getData.
This commit is contained in:
37
lodash.js
37
lodash.js
@@ -27,9 +27,6 @@
|
||||
var HOT_COUNT = 150,
|
||||
HOT_SPAN = 16;
|
||||
|
||||
/** Used as the property name for wrapper metadata */
|
||||
var EXPANDO = '__lodash_' + VERSION.replace(/[-.]/g, '_') + '__';
|
||||
|
||||
/** Used as the TypeError message for "Functions" methods */
|
||||
var FUNC_ERROR_TEXT = 'Expected a function';
|
||||
|
||||
@@ -722,17 +719,6 @@
|
||||
return result;
|
||||
}());
|
||||
|
||||
/** Used to set metadata on functions */
|
||||
var defineProperty = (function() {
|
||||
// IE 8 only accepts DOM elements
|
||||
try {
|
||||
var o = {},
|
||||
func = isNative(func = Object.defineProperty) && func,
|
||||
result = func(o, o, o) && func;
|
||||
} catch(e) {}
|
||||
return result;
|
||||
}());
|
||||
|
||||
/* Native method references for those with the same name as other `lodash` methods */
|
||||
var nativeCreate = isNative(nativeCreate = Object.create) && nativeCreate,
|
||||
nativeIsArray = isNative(nativeIsArray = Array.isArray) && nativeIsArray,
|
||||
@@ -2226,19 +2212,10 @@
|
||||
* @param {*} data The metadata.
|
||||
* @returns {Function} Returns `func`.
|
||||
*/
|
||||
function baseSetData(func, data) {
|
||||
var baseSetData = !WeakMap ? identity : function(func, data) {
|
||||
metaMap.set(func, data);
|
||||
return func;
|
||||
}
|
||||
// fallback for environments without `WeakMap`
|
||||
if (!WeakMap) {
|
||||
baseSetData = !defineProperty ? identity : function(func, value) {
|
||||
descriptor.value = value;
|
||||
defineProperty(func, EXPANDO, descriptor);
|
||||
descriptor.value = null;
|
||||
return func;
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The base implementation of `_.some` without support for callback shorthands
|
||||
@@ -2831,15 +2808,9 @@
|
||||
* @param {Function} func The function to query.
|
||||
* @returns {*} Returns the metadata for `func`.
|
||||
*/
|
||||
function getData(func) {
|
||||
var getData = !WeakMap ? noop : function(func) {
|
||||
return metaMap.get(func);
|
||||
}
|
||||
// fallback for environments without `WeakMap`
|
||||
if (!WeakMap) {
|
||||
getData = !defineProperty ? noop : function(func) {
|
||||
return func[EXPANDO];
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the appropriate "indexOf" function. If the `_.indexOf` method is
|
||||
|
||||
Reference in New Issue
Block a user