diff options
Diffstat (limited to 'packages/idb-bridge/src/util/extractKey.ts')
-rw-r--r-- | packages/idb-bridge/src/util/extractKey.ts | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/packages/idb-bridge/src/util/extractKey.ts b/packages/idb-bridge/src/util/extractKey.ts index 09306ddec..2a4ec45b9 100644 --- a/packages/idb-bridge/src/util/extractKey.ts +++ b/packages/idb-bridge/src/util/extractKey.ts @@ -15,11 +15,15 @@ permissions and limitations under the License. */ -import { IDBKeyPath, IDBValidKey } from "../idbtypes"; -import { valueToKey } from "./valueToKey"; +import { IDBKeyPath, IDBValidKey } from "../idbtypes.js"; +import { valueToKey } from "./valueToKey.js"; // http://www.w3.org/TR/2015/REC-IndexedDB-20150108/#dfn-steps-for-extracting-a-key-from-a-value-using-a-key-path +/** + * Algorithm to "extract a key from a value using a key path". + */ export const extractKey = (keyPath: IDBKeyPath | IDBKeyPath[], value: any) => { + //console.log(`extracting key ${JSON.stringify(keyPath)} from ${JSON.stringify(value)}`); if (Array.isArray(keyPath)) { const result: IDBValidKey[] = []; @@ -59,7 +63,7 @@ export const extractKey = (keyPath: IDBKeyPath | IDBKeyPath[], value: any) => { remainingKeyPath = null; } - if (!object.hasOwnProperty(identifier)) { + if (object == null || !object.hasOwnProperty(identifier)) { return; } |