Lint and fix failing tests

This commit is contained in:
Ray Schamp 2017-04-27 17:49:57 -04:00
parent c9ce6776aa
commit f785117e1d
8 changed files with 38 additions and 19 deletions
src/serialization

View file

@ -276,7 +276,7 @@ const parseScratchObject = function (object, runtime, topLevel) {
/**
* Top-level handler. Parse provided JSON,
* and process the top-level object (the stage object).
* @param {!string} json SB2-format JSON to load.
* @param {!object} json SB2-format JSON to load.
* @param {!Runtime} runtime Runtime object to load all structures into.
* @param {boolean=} optForceSprite If set, treat as sprite (Sprite2).
* @return {?Promise} Promise that resolves to the loaded targets when ready.

View file

@ -16,7 +16,7 @@ const loadSound = require('../import/load-sound.js');
/**
* Serializes the specified VM runtime.
* @param {!Runtime} runtime VM runtime instance to be serialized.
* @return {string} Serialized runtime instance.
* @return {object} Serialized runtime instance.
*/
const serialize = function (runtime) {
// Fetch targets
@ -150,11 +150,12 @@ const parseScratchObject = function (object, runtime) {
/**
* Deserializes the specified representation of a VM runtime and loads it into
* the provided runtime instance.
* @param {string} json Stringified JSON representation of a VM runtime.
* @param {object} json JSON representation of a VM runtime.
* @param {Runtime} runtime Runtime instance
* @returns {Promise} Promise that resolves to the list of targets after the project is deserialized
*/
const deserialize = function (json, runtime) {
return Promise.all(json.targets.map(target => parseScratchObject(target, runtime)));
return Promise.all((json.targets || []).map(target => parseScratchObject(target, runtime)));
};
module.exports = {