genshin-store
v1.0.0
Published
A lightweight JavaScript library for efficiently using local storage, session storage, and cookies.
Downloads
2
Readme
Light Storage
A lightweight JavaScript library for efficiently using local storage, session storage, and cookies.
Description
light-storage
provides a simple and intuitive API for storing and retrieving data in a way that is easy to use and understand.
Installation
npm install light-storage
Usage
import lightStorage from 'light-storage';
Local Storage
Set item with expiration time
lightStorage.setLocalItem('key', 'value', 3600000); // expires in 1 hour
Get Item
const value = lightStorage.getLocalItem('key');
Remove Item
lightStorage.removeLocalItem('key');
Clear all items
lightStorage.clearLocalItems();
Example
import lightStorage from 'light-storage';
// Set local storage item with expiration time
lightStorage.setLocalItem('username', 'John Doe', 3600000);
// Get local storage item
const username = lightStorage.getLocalItem('username');
console.log(username); // Output: John Doe
// Set session storage item
lightStorage.setSessionItem('isLoggedIn', true);
// Get session storage item
const isLoggedIn = lightStorage.getSessionItem('isLoggedIn');
console.log(isLoggedIn); // Output: true
// Set cookie with expiration time
lightStorage.setCookie('rememberMe', true, 3600000);
// Get cookie
const rememberMe = lightStorage.getCookie('rememberMe');
console.log(rememberMe); // Output: true