🚀 DAY 5 OF LAUNCH WEEK:Introducing Webhook Events for Alert Changes.Learn more
Socket
Book a DemoInstallSign in
Socket

symstorage

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

symstorage

前端存储方案的简易封装

latest
Source
npmnpm
Version
1.0.3
Version published
Maintainers
1
Created
Source

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

Keywords

storage

FAQs

Package last updated on 06 Jun 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts