format menu

This commit is contained in:
Valerie Young 2018-12-11 14:53:38 -05:00 committed by Valerie Young
parent e4d9f9cdff
commit c305379393

View file

@ -197,6 +197,35 @@ class Scratch3GoForceBlocks {
return Promise.resolve(); return Promise.resolve();
} }
/**
* Formats menus into a format suitable for block menus, and loading previously
* saved projects:
* [
* {
* text: label,
* value: index
* },
* {
* text: label,
* value: index
* },
* etc...
* ]
*
* @param {array} menu - a menu to format.
* @return {object} - a formatted menu as an object.
* @private
*/
_formatMenu (menu) {
const m = [];
for (let i = 0; i < menu.length; i++) {
const obj = {};
obj.text = menu[i];
obj.value = i.toString();
m.push(obj);
}
return m;
}
} }
module.exports = Scratch3GoForceBlocks; module.exports = Scratch3GoForceBlocks;