missing structuredClone caused unintended mutations

This commit is contained in:
Florian Dold 2019-08-15 23:27:17 +02:00
parent 61bc36b90a
commit 78f885db3d
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
2 changed files with 5 additions and 5 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "idb-bridge", "name": "idb-bridge",
"version": "0.0.1", "version": "0.0.2",
"description": "IndexedDB implementation that uses SQLite3 as storage", "description": "IndexedDB implementation that uses SQLite3 as storage",
"main": "./build/index.js", "main": "./build/index.js",
"types": "./build/index.d.ts", "types": "./build/index.d.ts",

View File

@ -1027,7 +1027,7 @@ export class MemoryBackend implements Backend {
if (!result) { if (!result) {
throw Error("invariant violated"); throw Error("invariant violated");
} }
values.push(result.value); values.push(structuredClone(result.value));
} }
} }
} else { } else {
@ -1086,7 +1086,7 @@ export class MemoryBackend implements Backend {
} }
if (req.resultLevel >= ResultLevel.Full) { if (req.resultLevel >= ResultLevel.Full) {
values.push(res.value); values.push(structuredClone(res.value));
} }
numResults++; numResults++;
@ -1168,8 +1168,8 @@ export class MemoryBackend implements Backend {
} }
const objectStoreRecord: ObjectStoreRecord = { const objectStoreRecord: ObjectStoreRecord = {
primaryKey: key, primaryKey: structuredClone(key),
value: value, value: structuredClone(value),
}; };
objectStore.modifiedData = modifiedData.with(key, objectStoreRecord, true); objectStore.modifiedData = modifiedData.with(key, objectStoreRecord, true);