mirror of
https://github.com/photonstorm/phaser
synced 2025-03-06 00:07:31 +00:00
36 lines
765 B
JavaScript
36 lines
765 B
JavaScript
/**
|
|
* @author Richard Davey <rich@photonstorm.com>
|
|
* @copyright 2019 Photon Storm Ltd.
|
|
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
|
*/
|
|
|
|
/**
|
|
* Shallow Object Clone. Will not clone nested objects.
|
|
*
|
|
* @function Phaser.Utils.Objects.Clone
|
|
* @since 3.0.0
|
|
*
|
|
* @param {object} obj - the object from which to clone
|
|
*
|
|
* @return {object} a new object with the same properties as the input obj
|
|
*/
|
|
var Clone = function (obj)
|
|
{
|
|
var clone = {};
|
|
|
|
for (var key in obj)
|
|
{
|
|
if (Array.isArray(obj[key]))
|
|
{
|
|
clone[key] = obj[key].slice(0);
|
|
}
|
|
else
|
|
{
|
|
clone[key] = obj[key];
|
|
}
|
|
}
|
|
|
|
return clone;
|
|
};
|
|
|
|
module.exports = Clone;
|