From 23928a4815b00a704aa27cecd736d2ffb820ef1a Mon Sep 17 00:00:00 2001 From: izure Date: Thu, 21 Nov 2024 06:19:49 +0900 Subject: [PATCH] fix: resolve potential errors during garbage collection process --- README.md | 2 +- deno.json | 2 +- package.json | 2 +- src/utils/InvertedWeakMap.ts | 7 +++++++ 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ef9b01f..9e3e137 100644 --- a/README.md +++ b/README.md @@ -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' ``` diff --git a/deno.json b/deno.json index c8b100d..5167da7 100644 --- a/deno.json +++ b/deno.json @@ -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 ", "license": "MIT", diff --git a/package.json b/package.json index 1466729..de27986 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/utils/InvertedWeakMap.ts b/src/utils/InvertedWeakMap.ts index 64a015a..0bae4dc 100644 --- a/src/utils/InvertedWeakMap.ts +++ b/src/utils/InvertedWeakMap.ts @@ -12,6 +12,13 @@ export class InvertedWeakMap } 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) }