# temp-data

> 简单的临时数据存放，数据操作和普通对象一样简单

Latest version **1.0.4** (published 2017-03-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install temp-data
pnpm add temp-data
yarn add temp-data
bun add temp-data
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2017-03-06 |
| First published | 2017-02-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | laomu1988@qq.com |
| Maintainers | laomu |

## Links

- npm: https://www.npmjs.com/package/temp-data
- Repository: https://github.com/laomu1988/temp-data
- Homepage: https://github.com/laomu1988/temp-data#readme
- Issues: https://github.com/laomu1988/temp-data/issues
- npm.io page: https://npm.io/package/temp-data

## Dependencies (2)

- [lodash](https://npm.io/package/lodash.md) ^4.17.4
- [object-hash](https://npm.io/package/object-hash.md) ^1.1.5

## Recent versions

- 1.0.4 (latest) — 2017-03-06
- 1.0.3 — 2017-03-06
- 1.0.2 — 2017-02-10
- 1.0.1 — 2017-02-10
- 1.0.0 — 2017-02-10

## README

# 简单的临时数据存放，数据操作和普通对象一样简单
将数据存储下来，下次启动程序后会自动从本地读取数据


## 安装
```sh
npm install temp-data --save
```

## 使用
```js
var db = require('temp-data');
var temp = db(__dirname + '/temp.json',
    {
        count: 0
    },
    {
        timeout: 100
    }
);

if(!temp.count)  temp.count = 0;
// 统计程序启动的次数
temp.count += 1;
temp.$save();
```

## 函数及参数
* 初始化
    - path:        保存数据的路径
    - defaultData: 默认数据
    - config      配置对象
        - timeout: 保存数据延迟时间,避免短时间内重复操作，单位ms，默认10000ms
* $save(isRightNow) 比较当前数据是否改变，假如改变则存储到本地。 其中使用的lodash的节流函数，无需担心短时间内多次操作
    - isRightNow:  是否立即存储(不使用节流函数),默认false


## 注意事项：
* temp.__hash 将会用来存放对象的hash值，请不要使用这个变量

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