Don't clean costume and sound lists

They are already clean, since we don't store the data on them any more.
This commit is contained in:
Ray Schamp 2017-05-04 13:03:42 -04:00
parent efe31f4825
commit baee9a2793
2 changed files with 3 additions and 20 deletions

View file

@ -764,29 +764,12 @@ class RenderedTarget extends Target {
}
/**
* Helper method to clean out data from each asset when serializing to JSON
* @param {Array<object>} assetList list of costumes or sounds
* @returns {Array<object>} list with raw data removed from each asset
*/
assetListToJSON (assetList) {
const exclude = ['data', 'url'];
return assetList.map(asset => {
if (typeof asset !== 'object') return asset;
return Object.keys(asset).reduce((rAsset, prop) => {
if (exclude.indexOf(prop) === -1) rAsset[prop] = asset[prop];
return rAsset;
}, {});
});
}
/**
* Serialize sprite info, used when emitting events about the sprite
* @returns {object} Sprite data as a simple object
*/
toJSON () {
const costumes = this.assetListToJSON(this.getCostumes());
const sounds = this.assetListToJSON(this.getSounds());
const costumes = this.getCostumes();
return {
id: this.id,
name: this.getName(),
@ -805,7 +788,7 @@ class RenderedTarget extends Target {
variables: this.variables,
lists: this.lists,
costumes: costumes,
sounds: sounds
sounds: this.getSounds()
};
}

File diff suppressed because one or more lines are too long