mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 02:47:50 +00:00
Minor cleanup.
This commit is contained in:
30
lodash.js
30
lodash.js
@@ -1357,7 +1357,7 @@
|
|||||||
isShallow = !isDeep;
|
isShallow = !isDeep;
|
||||||
|
|
||||||
if (isArr) {
|
if (isArr) {
|
||||||
result = isDeep ? value.constructor(value.length) : slice(value);
|
result = isShallow ? slice(value) : value.constructor(value.length);
|
||||||
|
|
||||||
// add array properties assigned by `RegExp#exec`
|
// add array properties assigned by `RegExp#exec`
|
||||||
if (typeof value[0] == 'string' && hasOwnProperty.call(value, 'index')) {
|
if (typeof value[0] == 'string' && hasOwnProperty.call(value, 'index')) {
|
||||||
@@ -1381,9 +1381,9 @@
|
|||||||
|
|
||||||
if (isShallow && (isArgs || isObj)) {
|
if (isShallow && (isArgs || isObj)) {
|
||||||
result = baseAssign({}, value);
|
result = baseAssign({}, value);
|
||||||
}
|
if (isObj) {
|
||||||
if (isShallow && isObj) {
|
return result;
|
||||||
return result;
|
}
|
||||||
}
|
}
|
||||||
var Ctor = value.constructor;
|
var Ctor = value.constructor;
|
||||||
if (className == objectClass && !(isFunction(Ctor) && (Ctor instanceof Ctor))) {
|
if (className == objectClass && !(isFunction(Ctor) && (Ctor instanceof Ctor))) {
|
||||||
@@ -1427,16 +1427,14 @@
|
|||||||
if (isShallow) {
|
if (isShallow) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if (isDeep) {
|
// check for circular references and return corresponding clone
|
||||||
// check for circular references and return corresponding clone
|
stackA || (stackA = []);
|
||||||
stackA || (stackA = []);
|
stackB || (stackB = []);
|
||||||
stackB || (stackB = []);
|
|
||||||
|
|
||||||
var length = stackA.length;
|
var length = stackA.length;
|
||||||
while (length--) {
|
while (length--) {
|
||||||
if (stackA[length] == value) {
|
if (stackA[length] == value) {
|
||||||
return stackB[length];
|
return stackB[length];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// add the source value to the stack of traversed objects
|
// add the source value to the stack of traversed objects
|
||||||
@@ -2162,9 +2160,9 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
var result = customizer ? customizer(value, srcValue, key, object, source) : undefined,
|
var result = customizer ? customizer(value, srcValue, key, object, source) : undefined,
|
||||||
isShallow = typeof result != 'undefined';
|
isDeep = typeof result == 'undefined';
|
||||||
|
|
||||||
if (!isShallow) {
|
if (isDeep) {
|
||||||
result = isArr
|
result = isArr
|
||||||
? (isArray(value) ? value : [])
|
? (isArray(value) ? value : [])
|
||||||
: (isPlainObject(value) ? value : {});
|
: (isPlainObject(value) ? value : {});
|
||||||
@@ -2175,7 +2173,7 @@
|
|||||||
stackB.push(result);
|
stackB.push(result);
|
||||||
|
|
||||||
// recursively merge objects and arrays (susceptible to call stack limits)
|
// recursively merge objects and arrays (susceptible to call stack limits)
|
||||||
if (!isShallow) {
|
if (isDeep) {
|
||||||
baseMerge(result, srcValue, customizer, stackA, stackB);
|
baseMerge(result, srcValue, customizer, stackA, stackB);
|
||||||
}
|
}
|
||||||
object[key] = result;
|
object[key] = result;
|
||||||
|
|||||||
Reference in New Issue
Block a user