idb-bridge: fix deletion

This commit is contained in:
Florian Dold 2019-11-21 20:39:53 +01:00
parent 61558e00ae
commit e8f362ccfe
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
2 changed files with 11 additions and 3 deletions

View File

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

View File

@ -871,14 +871,22 @@ export class MemoryBackend implements Backend {
} else {
currKey = range.lower;
// We have a range with an lowerOpen lower bound, so don't start
// deleting the upper bound. Instead start with the next higher key.
// deleting the lower bound. Instead start with the next higher key.
if (range.lowerOpen && currKey !== undefined) {
currKey = modifiedData.nextHigherKey(currKey);
}
}
// invariant: (currKey is undefined) or (currKey is a valid key)
// make sure that currKey is either undefined or pointing to an
// existing object.
let firstValue = modifiedData.get(currKey);
if (!firstValue) {
if (currKey !== undefined) {
currKey = modifiedData.nextHigherKey(currKey);
}
}
// loop invariant: (currKey is undefined) or (currKey is a valid key)
while (true) {
if (currKey === undefined) {
// nothing more to delete!