Skip to content

封装各种前端存储API,包括localstorage、sessionstorage、cookie、indexedDB

License

Notifications You must be signed in to change notification settings

QiYuOr2/storage

Repository files navigation

封装 Storage

目前实现了 localStorage、sessionStorage、Cookie、indexedDB 的封装

使用

npm i symstorage
import { local, cookie, session, memory, indexed } from 'symstorage';

// localStorage
local.set('key', value);
local.get('key');
local.remove('key');
local.clear();

// cookie
cookie.set('key', value);
cookie.get('key');
cookie.remove('key');
cookie.clear();

// ...
// indexedDB 需要异步操作
await indexed.get('key');

或者

<script src="https://cdn.jsdelivr.net/gh/xmy6364/storage/storage.min.js"></script>

<script>
  storage.local.set('key', value);
  // ...
</script>

体验 Demo

git clone https://github.com/xmy6364/storage.git

cd storage

npm install

npm run build

npm run dev

TODO

  • 封装 indexDB
  • Github Action 自动发布 npm

About

封装各种前端存储API,包括localstorage、sessionstorage、cookie、indexedDB

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published