Comparing version 0.0.4 to 0.0.5
@@ -228,1 +228,7 @@ // Copyright Joyent, Inc. and other Node contributors. | ||
}; | ||
EventEmitter.prototype.off = EventEmitter.prototype.removeAllListeners; | ||
EventEmitter.prototype.on = EventEmitter.prototype.addListener; | ||
EventEmitter.prototype.fire = EventEmitter.prototype.fireEvent = EventEmitter.prototype.emit; | ||
EventEmitter.prototype.clearAllEventListeners = EventEmitter.prototype.removeAllListeners; | ||
@@ -5,3 +5,3 @@ { | ||
"description": "Core JavaScript library for browser runtime", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"author": { | ||
@@ -8,0 +8,0 @@ "name": "fish" |
49
utils.js
@@ -70,13 +70,13 @@ /** | ||
/** | ||
* deepMerge 深度合并 | ||
* @param {Object} dest 被合并的对象 | ||
* @param {Object} src 发起合并的对象 | ||
* @param {Number} depth 合并深度 | ||
* @return {Object} 合并结束的对象 | ||
*/ | ||
function deepMerge(dest, src, depth) { | ||
var i, j, len, src, result = clone(dest), depth = depth || 0; | ||
console.log(depth,'depth') | ||
if(depth++ >= 3) { | ||
function deepClone(src) { | ||
return deepMerge({}, src); | ||
} | ||
var maxDepth = 3; | ||
function deepMerge(dest, src, isDirect, depth) { | ||
var i, j, len, src, depth = depth || 0; | ||
var result = isDirect ? dest : clone(dest); | ||
if (depth++ >= maxDepth) { | ||
console.log('层数过深, 全部继承'); | ||
@@ -91,7 +91,8 @@ return clone(src); | ||
if(value === destValue) continue; | ||
if(value === undefined || value === null) continue; | ||
if(value === undefined) continue; | ||
if (destValue && typeof (destValue) === 'object' && typeof (value) === 'object') { | ||
result[i] = deepMerge(destValue, value, depth); | ||
result[i] = deepMerge(destValue, value, isDirect, depth); | ||
continue; | ||
} | ||
if (typeof(value) === 'object' && (!isDirect)) value = deepMerge({}, value, false); | ||
result[i] = value; | ||
@@ -103,9 +104,17 @@ } | ||
function deepMergeCopy(dest, src){ | ||
return deepMerge(dest, src, false); | ||
} | ||
function deepMergeDirect(dest, src){ | ||
return deepMerge(dest, src, false); | ||
} | ||
module.exports = { | ||
merge: merge, | ||
isNone: isNone, | ||
traver: traver, | ||
deepMerge: deepMerge, | ||
clone: clone | ||
}; | ||
'merge': merge, | ||
'isNone': isNone, | ||
'traver': traver, | ||
'deepMerge': deepMerge, | ||
'deepMergeDirect': deepMergeDirect, | ||
'deepMergeCopy': deepMergeCopy, | ||
'clone': clone, | ||
'deepClone': deepClone | ||
}; |
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
20362
664
1