Document and test that saveProjectSb3DontZip does not copy asset buffers
This commit is contained in:
1 parent
20f53fa4d7
commit
cb2eba9eb3
2 files changed
+7
-1
No files matched your search
@@ -524,7 +524,9 @@ class VirtualMachine extends EventEmitter {
|
||||
|
||||
/**
|
||||
* tw: Serialize the project into a map of files without actually zipping the project.
|
||||
* @returns {Record<Uint8Array>} Files of the project.
|
||||
* The buffers returned are the exact same ones used internally, not copies. Avoid directly
|
||||
* manipulating them (except project.json, which is created by this function).
|
||||
* @returns {Record<string, Uint8Array>} Map of file name to the raw data for that file.
|
||||
*/
|
||||
saveProjectSb3DontZip () {
|
||||
const soundDescs = serializeSounds(this.runtime);
|
||||
|
||||
@@ -78,5 +78,9 @@ test('saveProjectSb3DontZip', async t => {
|
||||
t.equal(map['d9c625ae1996b615a146ac2a7dbe74d7.svg'].byteLength, 691);
|
||||
t.equal(map['cd21514d0531fdffb22204e0ec5ed84a.svg'].byteLength, 202);
|
||||
|
||||
// Make sure that the asset buffers returned are the exact same as the ones used internally, not copies.
|
||||
const costume = vm.runtime.targets[0].getCostumes()[0];
|
||||
t.equal(map['cd21514d0531fdffb22204e0ec5ed84a.svg'], costume.asset.data);
|
||||
|
||||
t.end();
|
||||
});
|
||||
Reference in new issue
Block a user