-
-
Notifications
You must be signed in to change notification settings - Fork 264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Keyed collections #962
Keyed collections #962
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is something i feel "solid" except for one case which we need to cover later.
nextIndex = data.length | ||
|
||
const vObject: InternalProxyObject<K, V> = { | ||
data, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need this not to rely on data.length
.
data, | |
data, | |
nextIndex, |
const k = maybeProxify(key) | ||
if (!indexMap.has(k) && !isProxy(this)) { | ||
// eslint-disable-next-line @typescript-eslint/no-unused-expressions | ||
this.data.length |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and this.
this.data.length | |
this.nextIndex |
if (this.data[index] !== undefined) { | ||
return this.data[index]![1] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's simplify unless there's a serious issue.
if (this.data[index] !== undefined) { | |
return this.data[index]![1] | |
} | |
return this.data[index]![1] |
const isProxy = (x: any) => proxyStateMap.has(x) | ||
|
||
type InternalProxyObject<K, V> = Map<K, V> & { | ||
data: Array<[K, V | undefined]> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data: Array<[K, V | undefined]> | |
data: Array<[K, V | undefined]> | |
nextIndex: number |
|
||
type InternalProxyObject<K, V> = Map<K, V> & { | ||
data: Array<[K, V | undefined]> | ||
size: number |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just curious: do we need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type definition? I could declare it when I create vObject
below if you prefer that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean I thought Map<K, V>
type already includes size
property.
|
||
Object.defineProperties(proxiedObject, { | ||
size: { enumerable: false }, | ||
data: { enumerable: false }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data: { enumerable: false }, | |
nextIndex: { enumerable: false }, |
please create a new branch in this repo and open a new pr. |
Related Bug Reports or Discussions
#943
Fixes #
N/A
Summary
Created new implementation for proxyMap and proxySet. Added benchmarks and a few new tests.
Check List
pnpm run prettier
for formatting code and docs