Skip to content

xukaishan/easy-stroage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

easy-stroage

Easier to use local storage

Installation

CDN

<script src="https://unpkg.com/@littlekai/[email protected]/dist/easy-stroage.iife.js"></script>

Npm

npm install @littlekai/easy-stroage

Usage

const prefix = 'demo_' // 前缀命名空间 namespaces 
const persistent = new STROAGE(localStorage, prefix); // localStorage
const session = new STROAGE(sessionStorage, prefix); // sessionStorage

const obj = { name: 'wangyibo', age: 32, children: [{ name: 'zs' }] }
const address = { name: 'wangyibo', age: 32 }

const setPersistent = () => {
    persistent.set('user', obj) // true
    persistent.set('user.address', '成华大道二仙桥') // true
}
const getPersistent = () => {
    persistent.get('user.children') // [{ name: 'zs' }]
    persistent.get('user.tel') // null
}

Demo

cd demo
npm i
npm run dev

About

More convenient use of local storage

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published