lodash.isplainobject
Advanced tools
Comparing version 3.1.0 to 3.2.0
67
index.js
/** | ||
* lodash 3.1.0 (Custom Build) <https://lodash.com/> | ||
* lodash 3.2.0 (Custom Build) <https://lodash.com/> | ||
* Build: `lodash modern modularize exports="npm" -o ./` | ||
@@ -10,3 +10,3 @@ * Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/> | ||
var baseFor = require('lodash._basefor'), | ||
getNative = require('lodash._getnative'), | ||
isArguments = require('lodash.isarguments'), | ||
keysIn = require('lodash.keysin'); | ||
@@ -35,3 +35,3 @@ | ||
/** | ||
* 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. | ||
@@ -41,5 +41,2 @@ */ | ||
/** Native method references. */ | ||
var getPrototypeOf = getNative(Object, 'getPrototypeOf'); | ||
/** | ||
@@ -59,33 +56,2 @@ * The base implementation of `_.forIn` without support for callback | ||
/** | ||
* 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; | ||
// Exit early for non `Object` objects. | ||
if (!(isObjectLike(value) && objToString.call(value) == objectTag) || | ||
(!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; | ||
// 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); | ||
} | ||
/** | ||
* Checks if `value` is a plain object, that is, an object created by the | ||
@@ -120,14 +86,23 @@ * `Object` constructor or one with a `[[Prototype]]` of `null`. | ||
*/ | ||
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); | ||
// 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); | ||
} | ||
return objProto | ||
? (value == objProto || getPrototypeOf(value) == objProto) | ||
: shimIsPlainObject(value); | ||
}; | ||
module.exports = isPlainObject; |
{ | ||
"name": "lodash.isplainobject", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"description": "The modern build of lodash’s `_.isPlainObject` as a module.", | ||
@@ -21,5 +21,5 @@ "homepage": "https://lodash.com/", | ||
"lodash._basefor": "^3.0.0", | ||
"lodash._getnative": "^3.0.0", | ||
"lodash.isarguments": "^3.0.0", | ||
"lodash.keysin": "^3.0.0" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# lodash.isplainobject v3.1.0 | ||
# lodash.isplainobject v3.2.0 | ||
@@ -20,2 +20,2 @@ The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash’s](https://lodash.com/) `_.isPlainObject` exported as a [Node.js](http://nodejs.org/)/[io.js](https://iojs.org/) module. | ||
See the [documentation](https://lodash.com/docs#isPlainObject) or [package source](https://github.com/lodash/lodash/blob/3.1.0-npm-packages/lodash.isplainobject) for more details. | ||
See the [documentation](https://lodash.com/docs#isPlainObject) or [package source](https://github.com/lodash/lodash/blob/3.2.0-npm-packages/lodash.isplainobject) for more details. |
6113
94
+ Addedlodash.isarguments@^3.0.0
- Removedlodash._getnative@^3.0.0
- Removedlodash._getnative@3.9.1(transitive)