mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-04 08:57:49 +00:00
Bump to v3.10.0.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import getNative from '../internal/getNative';
|
||||
import shimIsPlainObject from '../internal/shimIsPlainObject';
|
||||
import baseForIn from '../internal/baseForIn';
|
||||
import isArguments from './isArguments';
|
||||
import isObjectLike from '../internal/isObjectLike';
|
||||
|
||||
/** `Object#toString` result references. */
|
||||
var objectTag = '[object Object]';
|
||||
@@ -7,15 +8,15 @@ var objectTag = '[object Object]';
|
||||
/** Used for native method references. */
|
||||
var objectProto = Object.prototype;
|
||||
|
||||
/** Used to check objects for own properties. */
|
||||
var hasOwnProperty = objectProto.hasOwnProperty;
|
||||
|
||||
/**
|
||||
* Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring)
|
||||
* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
|
||||
* of values.
|
||||
*/
|
||||
var objToString = objectProto.toString;
|
||||
|
||||
/** Native method references. */
|
||||
var getPrototypeOf = getNative(Object, 'getPrototypeOf');
|
||||
|
||||
/**
|
||||
* Checks if `value` is a plain object, that is, an object created by the
|
||||
* `Object` constructor or one with a `[[Prototype]]` of `null`.
|
||||
@@ -46,16 +47,25 @@ var getPrototypeOf = getNative(Object, 'getPrototypeOf');
|
||||
* _.isPlainObject(Object.create(null));
|
||||
* // => true
|
||||
*/
|
||||
var isPlainObject = !getPrototypeOf ? shimIsPlainObject : function(value) {
|
||||
if (!(value && objToString.call(value) == objectTag)) {
|
||||
function isPlainObject(value) {
|
||||
var Ctor;
|
||||
|
||||
// Exit early for non `Object` objects.
|
||||
if (!(isObjectLike(value) && objToString.call(value) == objectTag && !isArguments(value)) ||
|
||||
(!hasOwnProperty.call(value, 'constructor') && (Ctor = value.constructor, typeof Ctor == 'function' && !(Ctor instanceof Ctor)))) {
|
||||
return false;
|
||||
}
|
||||
var valueOf = getNative(value, 'valueOf'),
|
||||
objProto = valueOf && (objProto = getPrototypeOf(valueOf)) && getPrototypeOf(objProto);
|
||||
|
||||
return objProto
|
||||
? (value == objProto || getPrototypeOf(value) == objProto)
|
||||
: shimIsPlainObject(value);
|
||||
};
|
||||
// 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;
|
||||
// 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);
|
||||
}
|
||||
|
||||
export default isPlainObject;
|
||||
|
||||
Reference in New Issue
Block a user