jest-localstorage-mock icon indicating copy to clipboard operation
jest-localstorage-mock copied to clipboard

Prevent key conflict and keep iterable behavior

Open iagodahlem opened this issue 5 years ago • 4 comments

This fixes #102.

Based on #66 I changed the current implementation of the LocalStorage class to be a factory function that uses a Proxy internally.

This way we avoid key conflicts and keeps the iterable behavior.

So given the storage object, we can call Object.entries/keys/values or even just call the storage object itself that it will resolve to an object with all and just the stored items in it, as the native implementation does.

iagodahlem avatar May 03 '19 21:05 iagodahlem

This looks great at first pass! Lemme figure out what's going on with Circle and get back to this

clarkbw avatar May 08 '19 18:05 clarkbw

Cool, thanks!

Do you think we should remove localStorage.__STORE__[<key>] references from the README and encourage people to use localStorage[<key>]?

iagodahlem avatar May 08 '19 19:05 iagodahlem

Yes!

Sent from my phone

On May 8, 2019, at 12:49 PM, Iago Dahlem Lorensini [email protected] wrote:

Cool, thanks!

Do you think we should remove localStorage.STORE[] references from the README and encourage people to use localStorage[]?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

clarkbw avatar May 08 '19 20:05 clarkbw

@clarkbw any updates?

iagodahlem avatar Jun 28 '19 17:06 iagodahlem