scratch-vm/src/util/clone.js

18 lines
494 B
JavaScript
Raw Normal View History

/**
* Methods for cloning JavaScript objects.
* @type {object}
*/
2017-04-17 19:42:48 -04:00
class Clone {
/**
* Deep-clone a "simple" object: one which can be fully expressed with JSON.
* Non-JSON values, such as functions, will be stripped from the clone.
* @param {object} original - the object to be cloned.
* @returns {object} a deep clone of the original object.
*/
static simple (original) {
return JSON.parse(JSON.stringify(original));
}
}
module.exports = Clone;