arcade-physics
Version:
Use Arcade Physics without Phaser.
36 lines • 1.06 kB
JavaScript
;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Deep Copy the given object or array.
*
* @function Phaser.Utils.Objects.DeepCopy
* @since 3.50.0
*
* @param {object} obj - The object to deep copy.
*
* @return {object} A deep copy of the original object.
*/
const DeepCopy = inObject => {
let outObject;
let value;
let key;
if (typeof inObject !== 'object' || inObject === null) {
// inObject is not an object
return inObject;
}
// Create an array or object to hold the values
outObject = Array.isArray(inObject) ? [] : {};
for (key in inObject) {
value = inObject[key];
// Recursively (deep) copy for nested objects, including arrays
outObject[key] = DeepCopy(value);
}
return outObject;
};
exports.default = DeepCopy;
//# sourceMappingURL=DeepCopy.js.map