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

Function copyRecurse

lib/test/angular/1.7.0/angular.js:1001–1034  ·  view source on GitHub ↗
(source, destination, maxDepth)

Source from the content-addressed store, hash-verified

999 return copyElement(source, maxDepth);
1000
1001 function copyRecurse(source, destination, maxDepth) {
1002 maxDepth--;
1003 if (maxDepth < 0) {
1004 return '...';
1005 }
1006 var h = destination.$$hashKey;
1007 var key;
1008 if (isArray(source)) {
1009 for (var i = 0, ii = source.length; i < ii; i++) {
1010 destination.push(copyElement(source[i], maxDepth));
1011 }
1012 } else if (isBlankObject(source)) {
1013 // createMap() fast path --- Safe to avoid hasOwnProperty check because prototype chain is empty
1014 for (key in source) {
1015 destination[key] = copyElement(source[key], maxDepth);
1016 }
1017 } else if (source && typeof source.hasOwnProperty === 'function') {
1018 // Slow path, which must rely on hasOwnProperty
1019 for (key in source) {
1020 if (source.hasOwnProperty(key)) {
1021 destination[key] = copyElement(source[key], maxDepth);
1022 }
1023 }
1024 } else {
1025 // Slowest path --- hasOwnProperty can't be called as a method
1026 for (key in source) {
1027 if (hasOwnProperty.call(source, key)) {
1028 destination[key] = copyElement(source[key], maxDepth);
1029 }
1030 }
1031 }
1032 setHashKey(destination, h);
1033 return destination;
1034 }
1035
1036 function copyElement(source, maxDepth) {
1037 // Simple values

Callers 2

copyFunction · 0.70
copyElementFunction · 0.70

Calls 4

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

Tested by

no test coverage detected