Comparing version 0.0.9 to 0.0.12
@@ -5,3 +5,3 @@ { | ||
"description": "Core JavaScript library for browser runtime", | ||
"version": "0.0.9", | ||
"version": "0.0.12", | ||
"author": { | ||
@@ -8,0 +8,0 @@ "name": "fish" |
40
utils.js
@@ -30,3 +30,3 @@ /** | ||
} | ||
var root = this | ||
/** | ||
@@ -79,4 +79,4 @@ * extend 合并方法 | ||
if(!d) return false; | ||
if(d instanceof HTMLElement) return false; | ||
if(d[0] && d[0] instanceof HTMLElement) return false; | ||
if(root.HTMLElement && d instanceof root.HTMLElement) return false; | ||
if(root.HTMLElement d[0] && d[0] instanceof HTMLElement) return false; | ||
if(d.globalCompositeOperation) return false;//ctx的情况 | ||
@@ -88,3 +88,3 @@ | ||
var maxDepth = 3; | ||
var maxDepth = 4; | ||
function deepMerge(dest, src, isDirect, depth) { | ||
@@ -107,2 +107,6 @@ var i, j, len, src, depth = depth || 0; | ||
if (destValue && typeof (destValue) === 'object' && typeof (value) === 'object') { | ||
if(!isNeedClone(value)){ | ||
result[i] = value; | ||
continue; | ||
} | ||
if(Array.isArray(destValue) !== Array.isArray(value)){ // 继承和被继承的 一个是数组 一个是对象 | ||
@@ -112,8 +116,8 @@ if (typeof(value) === 'object' && (!isDirect) && isNeedClone(value)) value = deepClone(value); | ||
continue; | ||
} else{ | ||
result[i] = deepMerge(destValue, value, isDirect, depth); | ||
continue; | ||
} | ||
} | ||
result[i] = deepMerge(destValue, value, isDirect, depth); | ||
continue; | ||
} | ||
if (typeof(value) === 'object' && (!isDirect) && isNeedClone(value)) value = deepClone(value); | ||
if (typeof (value) === 'object' && (!isDirect) && isNeedClone(value)) value = deepClone(value); | ||
result[i] = value; | ||
@@ -131,2 +135,17 @@ } | ||
} | ||
/** | ||
* switchValue 如果是非函数 返回本身 如果是函数 执行之,常用于options内部的判断 | ||
* @param {Any} f 函数或数值 | ||
* @param {Any} a 参数1 | ||
* @param {Any} b 参数2 | ||
* @param {Any} c 参数3 | ||
* @param {Any} d 参数4 | ||
* @return {Any} 返回值 | ||
*/ | ||
function switchValue(f, a, b, c, d){ | ||
if(typeof(f) === 'function') return f(a, b, c, d); | ||
return f; | ||
} | ||
module.exports = { | ||
@@ -140,3 +159,4 @@ 'merge': merge, | ||
'clone': clone, | ||
'deepClone': deepClone | ||
'deepClone': deepClone, | ||
'switchValue': switchValue | ||
}; |
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
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
21858
700