mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-03-13 17:04:39 -04:00
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:
parent
efe31f4825
commit
baee9a2793
2 changed files with 3 additions and 20 deletions
|
@ -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()
|
||||
};
|
||||
}
|
||||
|
||||
|
|
2
test/fixtures/demo.json
vendored
2
test/fixtures/demo.json
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue