Comparing version 0.0.20 to 0.0.21
@@ -5,3 +5,3 @@ { | ||
"description": "Core JavaScript library for browser runtime", | ||
"version": "0.0.20", | ||
"version": "0.0.21", | ||
"author": { | ||
@@ -8,0 +8,0 @@ "name": "fish" |
46
utils.js
@@ -124,2 +124,45 @@ /** | ||
function deepMergeWithoutArray(dest, src, directs, depth) { | ||
var i, j, len, src, depth = depth || 0; | ||
var result = clone(dest); | ||
if (depth >= maxDepth) { | ||
console.log('层数过深, 全部继承'); | ||
return src; | ||
} | ||
depth++; | ||
// | ||
for (i in src) { | ||
if (src.hasOwnProperty(i)) { | ||
var value = src[i]; | ||
var destValue = dest[i]; | ||
if(value === destValue) continue; | ||
if(value === undefined) continue; | ||
if (destValue && typeof (destValue) === 'object' && typeof (value) === 'object') { | ||
if (Array.isArray(destValue) && Array.isArray(value)) { | ||
result[i] = value; | ||
continue; | ||
} | ||
if (!isNeedClone(value) || (directs && i in directs)) { | ||
result[i] = value; | ||
continue; | ||
} | ||
if (Array.isArray(destValue) !== Array.isArray(value)) { // 继承和被继承的 一个是数组 一个是对象 | ||
value = deepClone(value); | ||
result[i] = value; | ||
continue; | ||
} | ||
result[i] = deepMergeWithoutArray(destValue, value, directs, depth); | ||
continue; | ||
} | ||
if (typeof (value) === 'object' && isNeedClone(value)) value = deepClone(value); | ||
result[i] = value; | ||
} | ||
} | ||
return result; | ||
} | ||
/** | ||
@@ -178,3 +221,4 @@ * switchValue 如果是非函数 返回本身 如果是函数 执行之,常用于options内部的判断 | ||
'deepClone': deepClone, | ||
'switchValue': switchValue | ||
'switchValue': switchValue, | ||
'deepMergeWithoutArray': deepMergeWithoutArray | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
41341
16
763
1