MCPcopy
hub / github.com/angular-ui/ui-router / copyRecurse

Function copyRecurse

test/angular/1.6/angular.js:1043–1076  ·  view source on GitHub ↗
(source, destination, maxDepth)

Source from the content-addressed store, hash-verified

1041 return copyElement(source, maxDepth);
1042
1043 function copyRecurse(source, destination, maxDepth) {
1044 maxDepth--;
1045 if (maxDepth < 0) {
1046 return '...';
1047 }
1048 var h = destination.$$hashKey;
1049 var key;
1050 if (isArray(source)) {
1051 for (var i = 0, ii = source.length; i < ii; i++) {
1052 destination.push(copyElement(source[i], maxDepth));
1053 }
1054 } else if (isBlankObject(source)) {
1055 // createMap() fast path --- Safe to avoid hasOwnProperty check because prototype chain is empty
1056 for (key in source) {
1057 destination[key] = copyElement(source[key], maxDepth);
1058 }
1059 } else if (source && typeof source.hasOwnProperty === 'function') {
1060 // Slow path, which must rely on hasOwnProperty
1061 for (key in source) {
1062 if (source.hasOwnProperty(key)) {
1063 destination[key] = copyElement(source[key], maxDepth);
1064 }
1065 }
1066 } else {
1067 // Slowest path --- hasOwnProperty can't be called as a method
1068 for (key in source) {
1069 if (hasOwnProperty.call(source, key)) {
1070 destination[key] = copyElement(source[key], maxDepth);
1071 }
1072 }
1073 }
1074 setHashKey(destination, h);
1075 return destination;
1076 }
1077
1078 function copyElement(source, maxDepth) {
1079 // Simple values

Callers 2

copyFunction · 0.70
copyElementFunction · 0.70

Calls 4

isArrayFunction · 0.85
copyElementFunction · 0.70
isBlankObjectFunction · 0.70
setHashKeyFunction · 0.70

Tested by

no test coverage detected