diff options
author | Florian Dold <florian@dold.me> | 2021-02-08 15:23:44 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2021-02-08 15:23:44 +0100 |
commit | 4452984a24334e3b7afb60e3db9dc12db02d65ba (patch) | |
tree | 50baf32f3a624d77346e38ba2bc573c063651ad2 /packages/idb-bridge/src/util/getIndexKeys.ts | |
parent | 883637d3f287e5026de5bcafb559ff3e6ba1f3bb (diff) | |
download | wallet-core-4452984a24334e3b7afb60e3db9dc12db02d65ba.tar.gz wallet-core-4452984a24334e3b7afb60e3db9dc12db02d65ba.tar.bz2 wallet-core-4452984a24334e3b7afb60e3db9dc12db02d65ba.zip |
idb-bridge: remove cyclic dependencies, rip out api extractor
Diffstat (limited to 'packages/idb-bridge/src/util/getIndexKeys.ts')
-rw-r--r-- | packages/idb-bridge/src/util/getIndexKeys.ts | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/packages/idb-bridge/src/util/getIndexKeys.ts b/packages/idb-bridge/src/util/getIndexKeys.ts index 253dc57bd..77b96b12f 100644 --- a/packages/idb-bridge/src/util/getIndexKeys.ts +++ b/packages/idb-bridge/src/util/getIndexKeys.ts @@ -15,15 +15,15 @@ permissions and limitations under the License. */ -import { Key, Value, KeyPath } from "./types"; +import { IDBKeyPath, IDBValidKey } from "../idbtypes"; import extractKey from "./extractKey"; import valueToKey from "./valueToKey"; export function getIndexKeys( - value: Value, - keyPath: KeyPath, + value: any, + keyPath: IDBKeyPath | IDBKeyPath[], multiEntry: boolean, -): Key[] { +): IDBValidKey[] { if (multiEntry && Array.isArray(keyPath)) { const keys = []; for (const subkeyPath of keyPath) { @@ -36,9 +36,11 @@ export function getIndexKeys( } } return keys; - } else { + } else if (typeof keyPath === "string" || Array.isArray(keyPath)) { let key = extractKey(keyPath, value); return [valueToKey(key)]; + } else { + throw Error(`unsupported key path: ${typeof keyPath}`); } } |