fake-storage
Fake storage is a library to work with session/local storage, it provides you different polyfills in case that these options are not available.
This library is exported as commonJS module, however it works in browser environments.
Table of contents
Usage
first of all download this library using npm:
npm install --save fa-storage
Then, in a javascript file with browserify/webpack/rollup or whatever library you like to bundle your apps.
/* it exposes sessionStorage and localStorage the mock process is at follows: - native session/local storage - cookie storage - in memory storage*/const localStorage = ; localStorage; const config = localStorage; // returns bar localStorage; const maybeNull = localStorage; // returns null localStorageclear; // removes everything from store
Support
Tested in these browsers:
- IE >= 10
- Chrome 48+
- Firefox 55+
- Edge 14+
- Safari 10+
Known limitations
Cookie and memory storage polyfills currently don't support the full behavior of native implementations.
Given this, these way of using the library currently is not supported:
const localStorage = ; localStoragesomething = 'asdf'; // storing a key valuelocalStoragesomething // getting the value