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

Function copyElement

test/angular/1.6/angular.js:1078–1109  ·  view source on GitHub ↗
(source, maxDepth)

Source from the content-addressed store, hash-verified

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