Skip to content

Commit

Permalink
fix: resolve potential errors during garbage collection process
Browse files Browse the repository at this point in the history
  • Loading branch information
izure1 committed Nov 20, 2024
1 parent 06cb224 commit 23928a4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ import {
ValueComparator,
NumericComparator,
StringComparator
} from 'https://cdn.jsdelivr.net/npm/serializable-bptree@5.x.x/dist/esm/index.min.js'
} from 'https://cdn.jsdelivr.net/npm/serializable-bptree@5/+esm'
</script>
```

Expand Down
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@izure/serializable-bptree",
"version": "5.0.2",
"version": "5.0.3",
"description": "Store the B+tree flexibly, not only in-memory.",
"author": "izure1 <[email protected]>",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "serializable-bptree",
"version": "5.0.2",
"version": "5.0.3",
"description": "Store the B+tree flexibly, not only in-memory.",
"types": "./dist/types/index.d.ts",
"main": "./dist/cjs/index.cjs",
Expand Down
7 changes: 7 additions & 0 deletions src/utils/InvertedWeakMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ export class InvertedWeakMap<K extends string|number|symbol, V extends WeakKey>
}

delete(key: K): boolean {
const ref = this._map.get(key)
if (ref) {
const raw = ref.deref()
if (raw !== undefined) {
this._registry.unregister(raw)
}
}
return this._map.delete(key)
}

Expand Down

0 comments on commit 23928a4

Please sign in to comment.