From 2c858636346c71a821c0022213b4812629d02947 Mon Sep 17 00:00:00 2001 From: Michael Sweeney Date: Thu, 10 Oct 2024 11:17:41 -0700 Subject: [PATCH] fixed delete, has and get --- src/vanilla/utils/proxyMap.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/vanilla/utils/proxyMap.ts b/src/vanilla/utils/proxyMap.ts index 7d13ee3d..6fb5f944 100644 --- a/src/vanilla/utils/proxyMap.ts +++ b/src/vanilla/utils/proxyMap.ts @@ -49,6 +49,10 @@ export function proxyMap(entries?: Iterable<[K, V]> | undefined | null) { }, get(key: K) { const k = maybeProxify(key) + if (!indexMap.has(k) && !isProxy(this)) { + // eslint-disable-next-line @typescript-eslint/no-unused-expressions + this.data.length + } if (indexMap.has(k)) { const index = indexMap.get(k)! if (this.data[index] !== undefined) { @@ -58,7 +62,12 @@ export function proxyMap(entries?: Iterable<[K, V]> | undefined | null) { return undefined }, has(key: K) { - return this.get(key) !== undefined + const k = maybeProxify(key) + if (!indexMap.has(k) && !isProxy(this)) { + // eslint-disable-next-line @typescript-eslint/no-unused-expressions + this.data.length + } + return indexMap.has(k) }, set(key: K, value: V) { if (!isProxy(this)) { @@ -89,10 +98,11 @@ export function proxyMap(entries?: Iterable<[K, V]> | undefined | null) { return false } } - if (indexMap.has(key)) { - const index = indexMap.get(key)! + const k = maybeProxify(key) + if (indexMap.has(k)) { + const index = indexMap.get(k)! delete this.data[index] - indexMap.delete(key) + indexMap.delete(k) emptyIndexes.push(index) return true }