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

Function shallowCopy

test/angular/1.5/angular.js:2411–2429  ·  view source on GitHub ↗

* Creates a shallow copy of an object, an array or a primitive. * * Assumes that there are no proto properties for objects.

(src, dst)

Source from the content-addressed store, hash-verified

2409 * Assumes that there are no proto properties for objects.
2410 */
2411function shallowCopy(src, dst) {
2412 if (isArray(src)) {
2413 dst = dst || [];
2414
2415 for (var i = 0, ii = src.length; i < ii; i++) {
2416 dst[i] = src[i];
2417 }
2418 } else if (isObject(src)) {
2419 dst = dst || {};
2420
2421 for (var key in src) {
2422 if (!(key.charAt(0) === '$' && key.charAt(1) === '$')) {
2423 dst[key] = src[key];
2424 }
2425 }
2426 }
2427
2428 return dst || src;
2429}
2430
2431/* global toDebugString: true */
2432

Callers 9

eventHandlerFunction · 0.70
angular.jsFile · 0.70
$HttpProviderFunction · 0.70
mergeHeadersFunction · 0.70
sendReqFunction · 0.70
resolvePromiseWithResultFunction · 0.70
$SceProviderFunction · 0.70
ngClassWatchActionFunction · 0.70
selectPreLinkFunction · 0.70

Calls 2

isArrayFunction · 0.85
isObjectFunction · 0.70

Tested by

no test coverage detected