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

1.0.2 • Public • Published

umbrella

umbrella of localStorage & sessionStorage between web apps

codecov travis-ci

说明

一个操作localStorage和sessionStorage的插件,避免同一个域名下部署不同前端web app,本地存储使用同样的key导致的冲突问题。

默认会使用域名+路径作为前缀(适用于hashRouter),对于BrowserRouter可以使用自定义前缀配置。

安装

yarn add umbrella-storage

使用

import umbrella from 'umbrella-storage';
 
umbrella.setLocalStorage('test', 'test');
umbrella.getLocalStorage('test');
 
umbrella.setSessionStorage('sessionTest', { name: 'test' });
umbrella.getSessionStorage('sessionTest');

API

// 配置自定义前缀
umbrella.config(prefix: string);
 
// 操作localStorage,value不需要转成字符串,自动帮忙处理
umbrella.setLocalStorage(key, value);
umbrella.getLocalStorage(key);
umbrella.removeLocalStorage(key);
 
// 操作localStorage,value不需要转成字符串,自动帮忙处理
umbrella.setSessionStorage(key, value);
umbrella.getSessionStorage(key);
umbrella.removeSessionStorage(key);
 

Package Sidebar

Install

npm i umbrella-storage

Weekly Downloads

43

Version

1.0.2

License

MIT

Unpacked Size

26 kB

Total Files

13

Last publish

Collaborators

  • yezihaohao