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

1.0.3 • Public • Published

封装 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

  • [x] 封装 indexDB
  • [x] Github Action 自动发布 npm

Package Sidebar

Install

npm i symstorage

Weekly Downloads

2

Version

1.0.3

License

MIT

Unpacked Size

22.1 kB

Total Files

11

Last publish

Collaborators

  • tuzilow