Closed Hotell closed 1 year ago
Let me see if I understand this correctly... When you do localStorage.keys
on a real instance of localStorage, you get back the keys you've stored, but when you do it on an instance of node-localstorage, you get back the administrative properties that node-localstorage caches. Correct?
Note, to get the keys from an instance of node-localstorage, you can do localStorage._keys
. I know how to make it behave the way I think you want it to behave and I've been meaning to upgrade to support the associative-array dot-property syntax so I'd be willing to work on that more rapidly if you were interested in helping or providing a bounty.
When you do localStorage.keys on a real instance of localStorage, you get back the keys you've stored, but when you do it on an instance of node-localstorage, you get back the administrative properties that node-localstorage caches. Correct?
yup that's correct.
Two options here, use defineProperties() and set the administrative ones as non enumerable, or use private attributes, that will be available in Node.js 12, that will be the new LTS in just two weeks.
Why was this closed? This is still an issue, and it breaks the promise of this library:
A drop-in substitute for the browser native localStorage API
I suspect that was before I implemented associative array and dot property syntax. Now that I've done that, this should be much easier. Reopening.
Finally got around to implementing this. If you are still around, let me know what you think @Hotell. It's in v3.0.2
webStorage is a abstracion which uses under the hood localstorage with proper parse/deserialize
where
webStorage.leys
==>Object.keys(window.localStorage)