Type definitions to retrieve objects from localStorage
8 points by groctel
8 points by groctel
You can use a custom toJSON and this becomes a lot more sane without all of the hoops, especially if your constructor also then symmetrically takes a json representation of your instance state.
It's a shame that IndexedDB has such an awful UI. That said, if you're going to be writing a wrapper for generic object storage in the browser and can afford for your operations to be async, I'd suggest wrapping IndexedDB instead, which allows storing much more data and does not require serializing and deserializing to/from strings in the application layer. You still have the problem of needing to rehydrate methods for non-builtin types; most of this article would still apply.