MCPcopy
hub / github.com/jquery/esprima / copy

Function copy

test/3rdparty/angular-1.2.5.js:801–840  ·  view source on GitHub ↗

* @ngdoc function * @name angular.copy * @function * * @description * Creates a deep copy of `source`, which should be an object or an array. * * * If no destination is supplied, a copy of the object or array is created. * * If a destination is provided, all of its elements (for array) or pr

(source, destination)

Source from the content-addressed store, hash-verified

799 </doc:example>
800 */
801function copy(source, destination){
802 if (isWindow(source) || isScope(source)) {
803 throw ngMinErr('cpws',
804 "Can't copy! Making copies of Window or Scope instances is not supported.");
805 }
806
807 if (!destination) {
808 destination = source;
809 if (source) {
810 if (isArray(source)) {
811 destination = copy(source, []);
812 } else if (isDate(source)) {
813 destination = new Date(source.getTime());
814 } else if (isRegExp(source)) {
815 destination = new RegExp(source.source);
816 } else if (isObject(source)) {
817 destination = copy(source, {});
818 }
819 }
820 } else {
821 if (source === destination) throw ngMinErr('cpi',
822 "Can't copy! Source and destination are identical.");
823 if (isArray(source)) {
824 destination.length = 0;
825 for ( var i = 0; i < source.length; i++) {
826 destination.push(copy(source[i]));
827 }
828 } else {
829 var h = destination.$$hashKey;
830 forEach(destination, function(value, key){
831 delete destination[key];
832 });
833 for ( var key in source) {
834 destination[key] = copy(source[key]);
835 }
836 setHashKey(destination,h);
837 }
838 }
839 return destination;
840}
841
842/**
843 * Create a shallow copy of an object

Callers 5

sendReqFunction · 0.85
$RootScopeProviderFunction · 0.85
$SceProviderFunction · 0.85
ngClassWatchActionFunction · 0.85
setupAsMultipleFunction · 0.85

Calls 9

isWindowFunction · 0.85
isScopeFunction · 0.85
isArrayFunction · 0.85
isDateFunction · 0.85
isRegExpFunction · 0.85
isObjectFunction · 0.85
setHashKeyFunction · 0.85
pushMethod · 0.80
forEachFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…