summaryrefslogtreecommitdiff
path: root/packages/idb-bridge/src/util/makeStoreKeyValue.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2021-02-25 16:34:55 +0100
committerFlorian Dold <florian@dold.me>2021-02-25 16:35:04 +0100
commit48acd573b1a470e54831e4388ea0e4fde410de30 (patch)
tree6cb7ff42c64ca45645ac9f812860f5c078ac70f2 /packages/idb-bridge/src/util/makeStoreKeyValue.ts
parent0e288650180380d0d1974eb2e0dfdcf57300f725 (diff)
downloadwallet-core-48acd573b1a470e54831e4388ea0e4fde410de30.tar.gz
wallet-core-48acd573b1a470e54831e4388ea0e4fde410de30.tar.bz2
wallet-core-48acd573b1a470e54831e4388ea0e4fde410de30.zip
idb: make test cases pass
Diffstat (limited to 'packages/idb-bridge/src/util/makeStoreKeyValue.ts')
-rw-r--r--packages/idb-bridge/src/util/makeStoreKeyValue.ts10
1 files changed, 7 insertions, 3 deletions
diff --git a/packages/idb-bridge/src/util/makeStoreKeyValue.ts b/packages/idb-bridge/src/util/makeStoreKeyValue.ts
index 243e46e04..c0fdb19a7 100644
--- a/packages/idb-bridge/src/util/makeStoreKeyValue.ts
+++ b/packages/idb-bridge/src/util/makeStoreKeyValue.ts
@@ -15,7 +15,7 @@
*/
import { extractKey } from "./extractKey";
-import { DataError } from "./errors";
+import { DataCloneError, DataError } from "./errors";
import { valueToKey } from "./valueToKey";
import { structuredClone } from "./structuredClone";
import { IDBKeyPath, IDBValidKey } from "../idbtypes";
@@ -26,7 +26,7 @@ export interface StoreKeyResult {
value: any;
}
-export function injectKey(
+function injectKey(
keyPath: IDBKeyPath | IDBKeyPath[],
value: any,
key: IDBValidKey,
@@ -87,7 +87,11 @@ export function makeStoreKeyValue(
// This models a decision table on (haveKey, haveKeyPath, autoIncrement)
- value = structuredClone(value);
+ try {
+ value = structuredClone(value);
+ } catch (e) {
+ throw new DataCloneError();
+ }
if (haveKey) {
if (haveKeyPath) {