Description
As stated in the serialization guide:
In most cases, this library uses
indexedDB
storage, which allows any value type. But in special cases (like in Firefox / IE private mode, see the browser support guide for details), the library will fall back tolocalStorage
, where JSON serialization will happen.
Everything can be serialized (
JSON.stringify()
), but when you unserialize (JSON.parse()
), you'll only get a JSON, ie. a primitive type, an array or a literal object.
So if you store an instance of a specific class in
localStorage
, likeDate
,Map
,Set
orBlob
, what you'll get then with.setItem()
won't be aMap
,Set
orBlob
, but just a literal object.
So, it's safer to stick to JSON-compatible values.
The library could add options to manage Date
, Map
or Set
automatically.
It requires:
- API design,
- time: I don't have time currently to implement new features, so sponsoring or community PRs are welcomed (after having agreed on the API design)