Bump to v3.7.0.

This commit is contained in:
John-David Dalton
2015-12-16 17:49:35 -08:00
parent 9724afd7a6
commit fec213a98c
121 changed files with 1686 additions and 815 deletions

View File

@@ -1,4 +1,4 @@
define([], function() {
define(['../internal/baseGet', '../internal/baseSlice', '../internal/isKey', '../array/last', '../internal/toPath'], function(baseGet, baseSlice, isKey, last, toPath) {
/** Used for native method references. */
var objectProto = Object.prototype;
@@ -7,24 +7,39 @@ define([], function() {
var hasOwnProperty = objectProto.hasOwnProperty;
/**
* Checks if `key` exists as a direct property of `object` instead of an
* inherited property.
* Checks if `path` is a direct property.
*
* @static
* @memberOf _
* @category Object
* @param {Object} object The object to inspect.
* @param {string} key The key to check.
* @returns {boolean} Returns `true` if `key` is a direct property, else `false`.
* @param {Object} object The object to query.
* @param {Array|string} path The path to check.
* @returns {boolean} Returns `true` if `path` is a direct property, else `false`.
* @example
*
* var object = { 'a': 1, 'b': 2, 'c': 3 };
* var object = { 'a': { 'b': { 'c': 3 } } };
*
* _.has(object, 'b');
* _.has(object, 'a');
* // => true
*
* _.has(object, 'a.b.c');
* // => true
*
* _.has(object, ['a', 'b', 'c']);
* // => true
*/
function has(object, key) {
return object ? hasOwnProperty.call(object, key) : false;
function has(object, path) {
if (object == null) {
return false;
}
var result = hasOwnProperty.call(object, path);
if (!result && !isKey(path)) {
path = toPath(path);
object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1));
path = last(path);
result = object != null && hasOwnProperty.call(object, path);
}
return result;
}
return has;