mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-11 19:37:49 +00:00
Add nativeKeysIn and cleanup object coercion.
This commit is contained in:
46
lodash.js
46
lodash.js
@@ -2468,14 +2468,13 @@
|
|||||||
if (object == null) {
|
if (object == null) {
|
||||||
return !length;
|
return !length;
|
||||||
}
|
}
|
||||||
var index = length;
|
object = Object(object);
|
||||||
while (index--) {
|
while (length--) {
|
||||||
var key = props[index],
|
var key = props[length],
|
||||||
predicate = source[key],
|
predicate = source[key],
|
||||||
value = object[key];
|
value = object[key];
|
||||||
|
|
||||||
if ((value === undefined &&
|
if ((value === undefined && !(key in object)) || !predicate(value)) {
|
||||||
!(key in Object(object))) || !predicate(value)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3248,12 +3247,12 @@
|
|||||||
* @returns {Array} Returns the array of property names.
|
* @returns {Array} Returns the array of property names.
|
||||||
*/
|
*/
|
||||||
function baseKeysIn(object) {
|
function baseKeysIn(object) {
|
||||||
var result = [];
|
if (object == null || !('constructor' in Object(object))) {
|
||||||
if (object == null) {
|
return nativeKeysIn(object);
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
object = Object(object);
|
var isProto = isPrototype(object),
|
||||||
var isProto = isPrototype(object);
|
result = [];
|
||||||
|
|
||||||
for (var key in object) {
|
for (var key in object) {
|
||||||
if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
|
if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
|
||||||
result.push(key);
|
result.push(key);
|
||||||
@@ -3346,7 +3345,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!(isArray(source) || isTypedArray(source))) {
|
if (!(isArray(source) || isTypedArray(source))) {
|
||||||
var props = keysIn(source);
|
var props = baseKeysIn(source);
|
||||||
}
|
}
|
||||||
arrayEach(props || source, function(srcValue, key) {
|
arrayEach(props || source, function(srcValue, key) {
|
||||||
if (props) {
|
if (props) {
|
||||||
@@ -6117,6 +6116,23 @@
|
|||||||
return objValue;
|
return objValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function is like
|
||||||
|
* [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
|
||||||
|
* except that it includes inherited enumerable properties.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {Object} object The object to query.
|
||||||
|
* @returns {Array} Returns the array of property names.
|
||||||
|
*/
|
||||||
|
function nativeKeysIn(object) {
|
||||||
|
var result = [];
|
||||||
|
for (var key in object) {
|
||||||
|
result.push(key);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the parent value at `path` of `object`.
|
* Gets the parent value at `path` of `object`.
|
||||||
*
|
*
|
||||||
@@ -12174,13 +12190,7 @@
|
|||||||
* // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
|
* // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
|
||||||
*/
|
*/
|
||||||
var assignIn = createAssigner(function(object, source) {
|
var assignIn = createAssigner(function(object, source) {
|
||||||
if (nonEnumShadows || isPrototype(source) || isArrayLike(source)) {
|
copyObject(source, keysIn(source), object);
|
||||||
copyObject(source, keysIn(source), object);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (var key in source) {
|
|
||||||
assignValue(object, key, source[key]);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user