voltace / browser-cookies

Tiny cookies library for the browser
The Unlicense
89 stars 18 forks source link

String values only? #20

Open YuriGor opened 5 years ago

YuriGor commented 5 years ago

At first I was wondering if it works with react, but then I found it supports string values only. So I'd recommend to add JSON serialization for set and deserialization for get. This will be backward compatible since string serialized to JSON remain just string. And for other cases it will greatly simplify lib usage. Now lib is absolutely confused when non-string passed to set method, it tries to use replace method without any check and throws unhandled errors. So to store and read simple boolean value user code will have to make a lot of frictions: toString() before set, and compare ==='true' on read.

YuriGor commented 5 years ago

Oh, I see there is related PR #18 but without JSON.parse