commit 78f885db3de3901e29c6841229df03327c2943fe
parent 61bc36b90aed99d161b28b9bc1742e7e1599546a
Author: Florian Dold <florian.dold@gmail.com>
Date: Thu, 15 Aug 2019 23:27:17 +0200
missing structuredClone caused unintended mutations
Diffstat:
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/packages/idb-bridge/package.json b/packages/idb-bridge/package.json
@@ -1,6 +1,6 @@
{
"name": "idb-bridge",
- "version": "0.0.1",
+ "version": "0.0.2",
"description": "IndexedDB implementation that uses SQLite3 as storage",
"main": "./build/index.js",
"types": "./build/index.d.ts",
diff --git a/packages/idb-bridge/src/MemoryBackend.ts b/packages/idb-bridge/src/MemoryBackend.ts
@@ -1027,7 +1027,7 @@ export class MemoryBackend implements Backend {
if (!result) {
throw Error("invariant violated");
}
- values.push(result.value);
+ values.push(structuredClone(result.value));
}
}
} else {
@@ -1086,7 +1086,7 @@ export class MemoryBackend implements Backend {
}
if (req.resultLevel >= ResultLevel.Full) {
- values.push(res.value);
+ values.push(structuredClone(res.value));
}
numResults++;
@@ -1168,8 +1168,8 @@ export class MemoryBackend implements Backend {
}
const objectStoreRecord: ObjectStoreRecord = {
- primaryKey: key,
- value: value,
+ primaryKey: structuredClone(key),
+ value: structuredClone(value),
};
objectStore.modifiedData = modifiedData.with(key, objectStoreRecord, true);