@joey-c/storage
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

storage

codecov

重写了storage

setValue('key', any);
<!-- 数据将以 JSON.stringify({ value: any }) 存入 -->

安装

npm install @joey-c/storage
or 
yarn add @joey-c/storage

使用

<!-- import -->
import { clearAll, localJStorage, sessionJStorage } from '@joey-c/storage';

<!-- localStorage 存 -->
localJStorage.setValue('key', 'hhhh');

<!-- localStorage 取 -->
const value = localJStorage.getValue('key');
console.log('storage', value);

<!-- localStorage 删除key -->
localJStorage.remove('key');

<!-- localStorage 清空 -->
localJStorage.clearAll();

<!-- sessionStorage 存 -->
sessionJStorage.setValue('sskey', ['sshhhh']);

<!-- sessionStorage 取 -->
const ssvalue = sessionJStorage.getValue('sskey');
console.log('storage', ssvalue);

<!-- sessionStorage 删除key -->
sessionJStorage.remove('sskey');

<!-- sessionStorage 清空 -->
sessionJStorage.clearAll();

<!-- 清空所有  localStorage、sessionStorage -->
clearAll();

标注

localJStorage 使用 window.localStorage

sessionJStorage 使用 window.sessionStorage

Readme

Keywords

Package Sidebar

Install

npm i @joey-c/storage

Weekly Downloads

0

Version

2.0.1

License

MIT

Unpacked Size

5.82 kB

Total Files

8

Last publish

Collaborators

  • joeyczz