Package Exports
- fallback-local-storage
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (fallback-local-storage) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Fallback Local Storage
Universal localStorage fallback
Install
npm install --save fallback-local-storage
bower install --save fallback-local-storage
Include
var FallbackLocalStorage = require("fallback-local-storage");
####Creating an instance:
if (FallbackLocalStorage.getStorage().includes("localStorage")) {
appStorage = localStorage;
} else {
appStorage = new FallbackLocalStorage;
}
FallbackLocalStorage.getStorage();
appStorage.setItem("hash", {name: "John"});
appStorage.getItem("isTurnedOn", false);
appStorage.removeItem("hash");
appStorage.hasItem("hash");
appStorage.keys();
appStorage.values();
appStorage.entries();
appStorage.forEach();
appStorage.toString();
appStorage.toJSON();
appStorage.length;
appStorage.clear();
If your browser supports localStorage
there is no point to replace it with fallback.
API
constructor (debug?: boolean, iterable?: boolean, autoSerialize?: boolean, CustomSerializer?: function)
- debug {boolean} (
false
) - toggle debug information output - iterable {boolean} (
false
) - allow iteration over instance - autoSerialize {boolean} (
false
) - serialize data before save - CustomSerializer {Function} - custom serializer for values
static getStorage (): Array
Return list of available storage
FallbackLocalStorage.getStorage();
[ 'localStorage', 'sessionStorage', 'fallbackStorage' ]