MCPcopy Create free account
hub / github.com/circircir-circle/human_exist_device / extend

Method extend

mini_program/common/Tools.js:352–399  ·  view source on GitHub ↗

* 扩展对象 * @return {Object}

()

Source from the content-addressed store, hash-verified

350 * @return {Object}
351 */
352 extend() {
353 let src, copyIsArray, copy, name, options, clone,
354 target = arguments[0] || {},
355 i = 1,
356 length = arguments.length,
357 deep = !1;
358
359 if (typeof target === 'boolean') {
360 deep = target
361 target = arguments[i] || {}
362 i++
363 }
364
365 if (typeof target !== 'object' && !this.isFunction(target)) {
366 target = {}
367 }
368
369 if (i === length) {
370 target = this
371 i--
372 }
373
374 for (; i < length; i++) {
375 if ((options = arguments[i]) != null) {
376 for (name in options) {
377 src = target[name]
378 copy = options[name]
379
380 if (target === copy) {
381 continue
382 }
383
384 if (deep && copy && (this.isPlainObject(copy) || (copyIsArray = this.isArray(copy)))) {
385 if (copyIsArray) {
386 copyIsArray = !1
387 clone = src && this.isArray(src) ? src : []
388 } else {
389 clone = src && this.isPlainObject(src) ? src : {}
390 }
391 target[name] = this.extend(deep, clone, copy)
392 } else if (copy !== undefined) {
393 target[name] = copy
394 }
395 }
396 }
397 }
398 return target
399 }
400
401 /**
402 * 判断传入的参数是否为纯粹的对象,即直接量{}或new Object()创建的对象

Callers 2

fhFunction · 0.80
echarts.jsFile · 0.80

Calls 3

isFunctionMethod · 0.95
isPlainObjectMethod · 0.95
isArrayMethod · 0.95

Tested by

no test coverage detected