0.0.1-1 • Published 2 years ago

ss-storage v0.0.1-1

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

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 --save

Data

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 string required: The key identifier of data to set
  • value any required: 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): any

Returns the current value associated with the given key, or null if the given key does not exist.