mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-11 11:27:50 +00:00
Remove _.isPlainObject fallback.
This commit is contained in:
@@ -765,7 +765,6 @@
|
|||||||
ceil = Math.ceil,
|
ceil = Math.ceil,
|
||||||
clearTimeout = context.clearTimeout,
|
clearTimeout = context.clearTimeout,
|
||||||
floor = Math.floor,
|
floor = Math.floor,
|
||||||
getPrototypeOf = getNative(Object, 'getPrototypeOf'),
|
|
||||||
parseFloat = context.parseFloat,
|
parseFloat = context.parseFloat,
|
||||||
push = arrayProto.push,
|
push = arrayProto.push,
|
||||||
propertyIsEnumerable = objectProto.propertyIsEnumerable,
|
propertyIsEnumerable = objectProto.propertyIsEnumerable,
|
||||||
@@ -4470,44 +4469,6 @@
|
|||||||
};
|
};
|
||||||
}());
|
}());
|
||||||
|
|
||||||
/**
|
|
||||||
* A fallback implementation of `_.isPlainObject` which checks if `value`
|
|
||||||
* is an object created by the `Object` constructor or has a `[[Prototype]]`
|
|
||||||
* of `null`.
|
|
||||||
*
|
|
||||||
* @private
|
|
||||||
* @param {*} value The value to check.
|
|
||||||
* @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
|
|
||||||
*/
|
|
||||||
function shimIsPlainObject(value) {
|
|
||||||
var Ctor,
|
|
||||||
support = lodash.support;
|
|
||||||
|
|
||||||
// Exit early for non `Object` objects.
|
|
||||||
if (!(isObjectLike(value) && objToString.call(value) == objectTag && !isHostObject(value) && !isArguments(value)) ||
|
|
||||||
(!hasOwnProperty.call(value, 'constructor') && (Ctor = value.constructor, typeof Ctor == 'function' && !(Ctor instanceof Ctor)))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// IE < 9 iterates inherited properties before own properties. If the first
|
|
||||||
// iterated property is an object's own property then there are no inherited
|
|
||||||
// enumerable properties.
|
|
||||||
var result;
|
|
||||||
if (support.ownLast) {
|
|
||||||
baseForIn(value, function(subValue, key, object) {
|
|
||||||
result = hasOwnProperty.call(object, key);
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
return result !== false;
|
|
||||||
}
|
|
||||||
// In most environments an object's own properties are iterated before
|
|
||||||
// its inherited properties. If the last iterated property is an object's
|
|
||||||
// own property then there are no inherited enumerable properties.
|
|
||||||
baseForIn(value, function(subValue, key) {
|
|
||||||
result = key;
|
|
||||||
});
|
|
||||||
return result === undefined || hasOwnProperty.call(value, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A fallback implementation of `Object.keys` which creates an array of the
|
* A fallback implementation of `Object.keys` which creates an array of the
|
||||||
* own enumerable property names of `object`.
|
* own enumerable property names of `object`.
|
||||||
@@ -9021,16 +8982,32 @@
|
|||||||
* _.isPlainObject(Object.create(null));
|
* _.isPlainObject(Object.create(null));
|
||||||
* // => true
|
* // => true
|
||||||
*/
|
*/
|
||||||
var isPlainObject = !getPrototypeOf ? shimIsPlainObject : function(value) {
|
function isPlainObject(value) {
|
||||||
if (!(value && objToString.call(value) == objectTag && !isArguments(value))) {
|
var Ctor;
|
||||||
|
|
||||||
|
// Exit early for non `Object` objects.
|
||||||
|
if (!(isObjectLike(value) && objToString.call(value) == objectTag && !isHostObject(value) && !isArguments(value)) ||
|
||||||
|
(!hasOwnProperty.call(value, 'constructor') && (Ctor = value.constructor, typeof Ctor == 'function' && !(Ctor instanceof Ctor)))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var valueOf = getNative(value, 'valueOf'),
|
// IE < 9 iterates inherited properties before own properties. If the first
|
||||||
objProto = valueOf && (objProto = getPrototypeOf(valueOf)) && getPrototypeOf(objProto);
|
// iterated property is an object's own property then there are no inherited
|
||||||
|
// enumerable properties.
|
||||||
return objProto
|
var result;
|
||||||
? (value == objProto || getPrototypeOf(value) == objProto)
|
if (lodash.support.ownLast) {
|
||||||
: shimIsPlainObject(value);
|
baseForIn(value, function(subValue, key, object) {
|
||||||
|
result = hasOwnProperty.call(object, key);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
return result !== false;
|
||||||
|
}
|
||||||
|
// In most environments an object's own properties are iterated before
|
||||||
|
// its inherited properties. If the last iterated property is an object's
|
||||||
|
// own property then there are no inherited enumerable properties.
|
||||||
|
baseForIn(value, function(subValue, key) {
|
||||||
|
result = key;
|
||||||
|
});
|
||||||
|
return result === undefined || hasOwnProperty.call(value, result);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user