@kscommon/easy-stroage
v1.0.2
Published
Wrapper for Axios that allows to easily requests
Downloads
1
Readme
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