lyc-storage
TypeScript icon, indicating that this package has built-in type declarations

1.0.7 • Public • Published

lyc-storage

包简答说明

这是一个对浏览器本地存储二次封装的库,支持过期与加密

使用例子

//以上初始化一个localstorage,进行加密,密钥是lyc
import { initStorage } from "lyc-storage"

const storage = initStorage("local",{
   isCrypto: true,
   sercetKey: 'lyc'
})

//存储,maxAge代表最大存在时间,maxAge是一个可选的参数
storage.set(key,value,maxAge)
//获取
storgae.get(key)
//删除
storage.remove(key)
//清除所有存储
storage.clear();
//获取已经使用的内存
storage.getSize();

//也可以不传入参数,默认创建一个localstorage,不加密
const sotrage = initStorage()
//也可以解构使用
const { get,set,remove,clear,getSize } = initStorage();
//用法与上面一样
set(key,value,maxAge)
get(key)
remove(key)
clear();
getSize()

Package Sidebar

Install

npm i lyc-storage

Weekly Downloads

9

Version

1.0.7

License

Apache

Unpacked Size

17.8 kB

Total Files

5

Last publish

Collaborators

  • lychao