This package has been deprecated

Author message:

this package will not be longer updated

fa-storage

1.2.3 • Public • Published

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 } = require('fa-storage');
 
 
 
localStorage.setItem('foo', 'bar');
 
const config = localStorage.getItem('foo'); // returns bar
 
localStorage.removeItem('foo');
 
const maybeNull = localStorage.getItem('unexisting key'); // returns null
 
localStorage.clear(); // 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 } = require('fa-storage');
 
localStorage.something = 'asdf'; // storing a key value
localStorage.something // getting the value
 

Readme

Keywords

Package Sidebar

Install

npm i fa-storage

Weekly Downloads

3

Version

1.2.3

License

MIT

Unpacked Size

15.4 kB

Total Files

15

Last publish

Collaborators

  • npm