-
Notifications
You must be signed in to change notification settings - Fork 2
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
Bug in deletePrefix(). #3
Comments
Your suggestion looks good to me, except with
to maintain the same semantics. |
@boxymoron do you want to make a PR? |
I've created a PR, so far just modified the test. I think I understand your point, but my test doesn't trigger a problem. Maybe I'm confused 🤔 |
@boxymoron ok. can you please check my #4 PR? |
@haraldschilly
The output is:
Also, I found another issue, LocalStorageLRU.clear() calls localStorage.clear(). While this is documented with a comment as such, I think it is problematic, as users of the library probably expect it to only clear entries "managed" by LocalStorageLRU, while it clears everything in localStorage (including key/values that were not "managed" by LocalStorageLRU). Maybe this merits another PR? |
@boxymoron so, thank you for explaining this. Version Regarding The only thought I have is: there could be a default prefix (by default, there is none, to match the current behavior) and all get/set/delete ops add that common prefix to all keys automatically. That way, this lib would have its own "namespace". |
@haraldschilly Aren't all the keys tracked in the
|
@haraldschilly Yes, it's working correctly now. Thank you for updating. |
well, no, only the recent ones. It's used by the |
The implementation of deletePrefix() is akin to removing an item from an array while iterating (i.e. doesn't work).
Possible Fix?:
The text was updated successfully, but these errors were encountered: