Skip to content

Commit

Permalink
fixed delete, has and get
Browse files Browse the repository at this point in the history
  • Loading branch information
overthemike committed Oct 10, 2024
1 parent 0b93c32 commit 2c85863
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/vanilla/utils/proxyMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ export function proxyMap<K, V>(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) {
Expand All @@ -58,7 +62,12 @@ export function proxyMap<K, V>(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)) {
Expand Down Expand Up @@ -89,10 +98,11 @@ export function proxyMap<K, V>(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
}
Expand Down

0 comments on commit 2c85863

Please sign in to comment.