Skip to content

Commit

Permalink
Added option to force reindexing when deleting from a list
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom committed Jul 1, 2021
1 parent d27a9f9 commit 0453fef
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/stormdb.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,19 @@ class StormDB {
return this;
}

delete() {
delete(reindexLists = false) {
let enclosing = this.state;
for (let i = 0; i < this.pointers.length - 1; i++) {
enclosing = enclosing[this.pointers[i]];
}

let final = this.pointers[this.pointers.length - 1];
delete enclosing[final];

if (Array.isArray(enclosing) && reindexLists) {
enclosing.splice(final, 1);
} else {
delete enclosing[final];
}
}

push(value) {
Expand Down

0 comments on commit 0453fef

Please sign in to comment.