# serialize-storage

> 将storage序列化，方便存取

Latest version **1.0.3** (published 2018-12-10) · ISC license · 0 weekly downloads

## Install

```sh
npm install serialize-storage
pnpm add serialize-storage
yarn add serialize-storage
bun add serialize-storage
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2018-12-10 |
| First published | 2018-12-08 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 29.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | yuyue |
| Maintainers | webbillion |
| Keywords | storage |

## Links

- npm: https://www.npmjs.com/package/serialize-storage
- Repository: https://github.com/webbillion/serialize-storage
- Homepage: https://github.com/webbillion/serialize-storage#readme
- Issues: https://github.com/webbillion/serialize-storage/issues
- npm.io page: https://npm.io/package/serialize-storage

## Dependencies (4)

- [rollup-plugin-babel](https://npm.io/package/rollup-plugin-babel.md) ^4.0.3
- [rollup-plugin-uglify](https://npm.io/package/rollup-plugin-uglify.md) ^6.0.0
- [rollup-plugin-commonjs](https://npm.io/package/rollup-plugin-commonjs.md) ^9.2.0
- [rollup-plugin-node-resolve](https://npm.io/package/rollup-plugin-node-resolve.md) ^3.4.0

## Alternatives

- [localforage](https://npm.io/package/localforage.md) — 6.2M weekly downloads
- [localforage-observable](https://npm.io/package/localforage-observable.md) — 30.8K weekly downloads
- [@y/y](https://npm.io/package/@y/y.md) — 30.1K weekly downloads
- [@metaobjectsdev/render](https://npm.io/package/@metaobjectsdev/render.md) — 3.5K weekly downloads
- [@ledgerhq/coin-algorand](https://npm.io/package/@ledgerhq/coin-algorand.md) — 1.1K weekly downloads

## Recent versions

- 1.0.3 (latest) — 2018-12-10
- 1.0.2 — 2018-12-10
- 1.0.1 — 2018-12-08

## README

## SerializeStorage
### 做什么的
可以更简单的获取和存储各种以键值对存储的Storage，如localStorage。
### 如何使用
```javascript
// 引入
import SerializeStorage from 'serialize-storage'
// 创建实例
const storage = new SerializeStorage(localStorage, {
  // 自动保存，默认为false，可以在getItem覆盖设置
  autoSave: false
  // 内置键前缀，建议不更改
  // keyPrefix: ''
})
// 获取数据
let item = storage.getItem('test')
// 设置和读取
console.log(item.value)
item.value = 4
// 默认需要手动保存
item.save()
// 移除
item.remove()
// 复杂的键
item = storage.getItem('test.test.1')
// 用实例而不是数据项来设置
storage.setItem('test', '')
// 在chrome扩展中可以使用异步版本
await storage.getItemAsync('test')
```
> 更多细节请参考测试用例
### TODO
- [x] 加入对chrome storage的异步支持
- [x] 完善声明文件
- [ ] 加入过期时间选项
- [ ] update方法

---
_Source: https://npm.io/package/serialize-storage · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
