Safe storage
Safe implementations for localStorage and sessionStorage, which fallbacks to in-memory implementation if default browser implementations aren't available. For example, when in private mode in Safari, storages are available, but an attempt to write to them throws an error.
Installation
npm i -S safe-storage
Usage
safe-storage
has the same signature as localStorage and sessionStorage, so you can use it as you would use normal localStorage or sessionStorage. Example:
; safeLocalStorage; console;// output: <123456789> console;// output: 1 safeLocalStorage; console;// output: null
For sessionStorage:
;