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

Function copyRecurse

test/angular/1.7/angular.js:1040–1073  ·  view source on GitHub ↗
(source, destination, maxDepth)

Source from the content-addressed store, hash-verified

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