basarat/typescript-collections

General pattern to update a key?

Closed this issue · 2 comments

Because of the reliance on string keys, it can be tricky to manage updates to a value that affect its key. For the identity map I made in this gist I came up with an update method that makes it pretty straightforward to keep the key in sync when mutations happen. Is this a pattern that could be useful across the library where string keys are in use?

https://gist.github.com/chriseppstein/11ae09e2d96f72af036645a481d879e3#file-identitydictionary-ts-L41-L62

I agree that reliance on string keys in JavaScript is sometimes troublesome but I would refrain from implementing that in the library since it's a core language feature. Most of the people is used to that.
Also, I would like to hear other people opinion on this.

Closing this because of old age. If the issue persists, discuss it here and/or open a Pull Request please.