Skip to content

xiayefeng/bs-store

Repository files navigation

bs-store

install

npm i bs-store -S

use example

import bsStore, {getSessionSize, getLocalSize} from 'bs-store'
import lzString from 'bs-store/lz-string'

bsStore.use(lzString) // 开启压缩模式,后同一应用不可再次设定

// 设置 sessionStorage
bsStore.setSession(key: string, val: number|boolean|string|object|[]<any>|bigint)

// 获取 sessionStorage
bsStore.getSession(key: string)

// 设置 localStorage
bsStore.setLocal(key: stirng, val: number|boolean|string|object|[]<any>|bigint)

// 获取 localStorage
bsStore.getLocal(key: string)

// 删除某个sessionStorage
bsStore.removeSession(key: string)
// 删除某个localStorage
bsStore.removeLocal(key: string)

// 删除所有 sessionStorage
bsStore.removeAllSession()
// 删除所有 localStorage
bsStore.removeAllLocal()

// 删除所有的 sessionStorage 和 localSorage
bsStore.removeAllStorage()

// 获取sessionStorage 已存数据大小
getSessionSize()

// 获取localStorage 已存数据大小
getLocalSize()

About

browser storage

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published