MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / merge

Function merge

libs/echarts/echarts.simple.js:357–392  ·  view source on GitHub ↗

* @memberOf module:zrender/core/util * @param {*} target * @param {*} source * @param {boolean} [overwrite=false]

(target, source, overwrite)

Source from the content-addressed store, hash-verified

355 * @param {boolean} [overwrite=false]
356 */
357function merge(target, source, overwrite) {
358 // We should escapse that source is string
359 // and enter for ... in ...
360 if (!isObject$1(source) || !isObject$1(target)) {
361 return overwrite ? clone(source) : target;
362 }
363
364 for (var key in source) {
365 if (source.hasOwnProperty(key)) {
366 var targetProp = target[key];
367 var sourceProp = source[key];
368
369 if (isObject$1(sourceProp)
370 && isObject$1(targetProp)
371 && !isArray(sourceProp)
372 && !isArray(targetProp)
373 && !isDom(sourceProp)
374 && !isDom(targetProp)
375 && !isBuiltInObject(sourceProp)
376 && !isBuiltInObject(targetProp)
377 && !isPrimitive(sourceProp)
378 && !isPrimitive(targetProp)
379 ) {
380 // 如果需要递归覆盖,就递归调用merge
381 merge(targetProp, sourceProp, overwrite);
382 }
383 else if (overwrite || !(key in target)) {
384 // 否则只处理overwrite为true,或者在目标对象中没有此属性的情况
385 // NOTE,在 target[key] 不存在的时候也是直接覆盖
386 target[key] = clone(source[key], true);
387 }
388 }
389 }
390
391 return target;
392}
393
394/**
395 * @param {Array} targetAndSources The first item is target, and the rests are source.

Callers 6

mergeAllFunction · 0.70
echarts.simple.jsFile · 0.70
mergeThemeFunction · 0.70
initBaseFunction · 0.70
compatEC2ItemStyleFunction · 0.70
axisModelCreatorFunction · 0.70

Calls 6

isObject$1Function · 0.70
cloneFunction · 0.70
isArrayFunction · 0.70
isDomFunction · 0.70
isBuiltInObjectFunction · 0.70
isPrimitiveFunction · 0.70

Tested by

no test coverage detected