mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-25 07:22:33 -05:00
Check if loadProject input is any typed array using ArrayBuffer.isView. This allows us to pass a project's asset.data (from storage) directly instead of calling toString on it first.
This commit is contained in:
parent
2c3e3472ed
commit
3a4f620318
1 changed files with 6 additions and 1 deletions
|
@ -182,8 +182,13 @@ class VirtualMachine extends EventEmitter {
|
||||||
* @return {!Promise} Promise that resolves after targets are installed.
|
* @return {!Promise} Promise that resolves after targets are installed.
|
||||||
*/
|
*/
|
||||||
loadProject (input) {
|
loadProject (input) {
|
||||||
if (typeof input === 'object' && !(input instanceof ArrayBuffer)) {
|
if (typeof input === 'object' && !ArrayBuffer.isView(input)) {
|
||||||
|
// If the input is an object and not any ArrayBuffer view
|
||||||
|
// (this includes all typed arrays and DataViews)
|
||||||
|
// turn the object into a JSON string, because we suspect
|
||||||
|
// this is a project.json as an object
|
||||||
// validate expects a string or buffer as input
|
// validate expects a string or buffer as input
|
||||||
|
// TODO not sure if we need to check that it also isn't a data view
|
||||||
input = JSON.stringify(input);
|
input = JSON.stringify(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue