1.0.2 • Published 1 year ago

@littlekai/easy-stroage v1.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

easy-stroage

Easier to use local storage

Installation

CDN

<script src="https://unpkg.com/@littlekai/easy-stroage@1.0.1/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
1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago