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

Function copyElement

test/angular/1.7/angular.js:1075–1106  ·  view source on GitHub ↗
(source, maxDepth)

Source from the content-addressed store, hash-verified

1073 }
1074
1075 function copyElement(source, maxDepth) {
1076 // Simple values
1077 if (!isObject(source)) {
1078 return source;
1079 }
1080
1081 // Already copied values
1082 var index = stackSource.indexOf(source);
1083 if (index !== -1) {
1084 return stackDest[index];
1085 }
1086
1087 if (isWindow(source) || isScope(source)) {
1088 throw ngMinErr('cpws',
1089 'Can\'t copy! Making copies of Window or Scope instances is not supported.');
1090 }
1091
1092 var needsRecurse = false;
1093 var destination = copyType(source);
1094
1095 if (destination === undefined) {
1096 destination = isArray(source) ? [] : Object.create(getPrototypeOf(source));
1097 needsRecurse = true;
1098 }
1099
1100 stackSource.push(source);
1101 stackDest.push(destination);
1102
1103 return needsRecurse
1104 ? copyRecurse(source, destination, maxDepth)
1105 : destination;
1106 }
1107
1108 function copyType(source) {
1109 switch (toString.call(source)) {

Callers 3

copyFunction · 0.70
copyRecurseFunction · 0.70
copyTypeFunction · 0.70

Calls 6

isArrayFunction · 0.85
isObjectFunction · 0.70
isWindowFunction · 0.70
isScopeFunction · 0.70
copyTypeFunction · 0.70
copyRecurseFunction · 0.70

Tested by

no test coverage detected