0.1.2 • Published 4 years ago

@divante/data-storage v0.1.2

Weekly downloads
3
License
UNLICENSED
Repository
-
Last release
4 years ago

Universal code for storing data in local storage or cookie, if local storage is not available.

Usage

Samples

let DataStorage = require('@divante/data-storage');

DataStorage.setValue("foo", "bar"); // setter
DataStorage.getValue("foo"); //returns "bar"

DataStorage.getValue("baz"); //returns undefined
DataStorage.getValue("baz", "default value"); //returns "default value"

DataStorage.isValueSet("foo"); //true
DataStorage.isValueSet("baz"); //false

DataStorage.setObjectValue("baz", {a: 15, b: [3, 4]}); //Stores as JSON
DataStorage.getObjectValue("baz"); // {a: 15, b: [3, 4]}
DataStorage.getObjectValue("baz2"); // undefined
DataStorage.getObjectValue("baz2", {}); // {}