A very simple way to manage browser storage.
If the browser doesn't support localStorage, data will be saved in a cookie. If the browser then doesn't support cookies either (not a lucky day!), it will be saved in a plain object! It also handles the QuotaExceeded error, silently logging it in the console and saving the data in the object.
npm install storage-helper
const storageKey = 'foo'const value = 'bar'// set itemstorageHelper// set an item not permanentlystorageHelper// get itemconst foo = storageHelper// get item parsedconst foo = storageHelper// remove itemstorageHelper// remove all itemsstorageHelperclear
It's also possible to export single functions from the module
The logger is by default set to false, so if you want to see logs during development, you can just do like so