MCPcopy Create free account
hub / github.com/cafebazaar/blacksmith / baseExtend

Function baseExtend

web/static/bower_components/angular/angular.js:412–440  ·  view source on GitHub ↗
(dst, objs, deep)

Source from the content-addressed store, hash-verified

410
411
412function baseExtend(dst, objs, deep) {
413 var h = dst.$$hashKey;
414
415 for (var i = 0, ii = objs.length; i < ii; ++i) {
416 var obj = objs[i];
417 if (!isObject(obj) && !isFunction(obj)) continue;
418 var keys = Object.keys(obj);
419 for (var j = 0, jj = keys.length; j < jj; j++) {
420 var key = keys[j];
421 var src = obj[key];
422
423 if (deep && isObject(src)) {
424 if (isDate(src)) {
425 dst[key] = new Date(src.valueOf());
426 } else if (isRegExp(src)) {
427 dst[key] = new RegExp(src);
428 } else {
429 if (!isObject(dst[key])) dst[key] = isArray(src) ? [] : {};
430 baseExtend(dst[key], [src], true);
431 }
432 } else {
433 dst[key] = src;
434 }
435 }
436 }
437
438 setHashKey(dst, h);
439 return dst;
440}
441
442/**
443 * @ngdoc function

Callers 2

extendFunction · 0.85
mergeFunction · 0.85

Calls 5

isObjectFunction · 0.85
isFunctionFunction · 0.85
isDateFunction · 0.85
isRegExpFunction · 0.85
setHashKeyFunction · 0.85

Tested by

no test coverage detected