MCPcopy
hub / github.com/phaserjs/phaser / DeepCopy

Function DeepCopy

src/utils/object/DeepCopy.js:19–43  ·  view source on GitHub ↗
(inObject)

Source from the content-addressed store, hash-verified

17 * @return {object} A deep copy of the original object or array.
18 */
19var DeepCopy = function (inObject)
20{
21 var outObject;
22 var value;
23 var key;
24
25 if (typeof inObject !== 'object' || inObject === null)
26 {
27 // inObject is not an object
28 return inObject;
29 }
30
31 // Create an array or object to hold the values
32 outObject = Array.isArray(inObject) ? [] : {};
33
34 for (key in inObject)
35 {
36 value = inObject[key];
37
38 // Recursively (deep) copy for nested objects, including arrays
39 outObject[key] = DeepCopy(value);
40 }
41
42 return outObject;
43};
44
45module.exports = DeepCopy;

Callers 9

ProgramManager.jsFile · 0.85
Tile.jsFile · 0.85
CreateFromTilesFunction · 0.85
ParseJSONTiledFunction · 0.85
MatterTileBody.jsFile · 0.85
RenderNodes.jsFile · 0.85
DeepCopy.test.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…