0.0.1-1 • Published 4 years ago
ss-storage v0.0.1-1
SS-STORAGE
ss-storage is used:
- Read data from the local storage
- Write data to the local storage
- Delete data from the local storage
- Clear the local storage
Usage
Installation
npm i ss-storage --saveData
const data = [1, 2, 3, 4];Import storage from 'ss-storage'
import storage from "ss-storage";Save to sessionstorage
storage.set("data", data);Read to sessionstorage
const myData = storage.get("data");console.log(myData);
// [1, 2, 3, 4]Delete data to sessionstorage
storage.remove("data");Clear sessionstorage
storage.clear();Set method
- Sets the value of the pair identified by key to value,
- creating a new key/value pair if none existed for key previously.
storage.set(key: string, value: any): any- key
stringrequired: The key identifier of data to set - value
anyrequired: The value to store
If the value is set, it will return the value, else it will return null
Get method
Retrieves a value from the storage
storage.get(key: string): anyReturns the current value associated with the given key, or null if the given key does not exist.