# fecache

> fecache for fetch or cache policy

Latest version **0.1.2** (published 2018-10-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install fecache
pnpm add fecache
yarn add fecache
bun add fecache
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2018-10-29 |
| First published | 2018-10-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 59.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | hyiso |
| Maintainers | hyiso |

## Links

- npm: https://www.npmjs.com/package/fecache
- Repository: https://github.com/hyiso/fecache
- Homepage: https://github.com/hyiso/fecache#readme
- Issues: https://github.com/hyiso/fecache/issues
- npm.io page: https://npm.io/package/fecache

## Recent versions

- 0.1.2 (latest) — 2018-10-29
- 0.1.1 — 2018-10-26
- 0.1.0 — 2018-10-18

## README

fecache: fetch or cache policy
-----

### usage
install:
```
yarn add fecache
```
js:
```
import fecache from 'fecache'

// default config
fecache.setDefaultRule(fecache.POLICY.ONLY_API, InInfinity)
fecache.setDefaultValidator(resp => resp.status == 200 && resp.data)

// single 
fecache.setRule(url, fecache.POLICY.FIRST_CACHE_SECOND_API, 1000 * 60 * 5)
fecache.setValidator(url, ({ data }) => data.code === 0 && data.list.length > 0)

fecache.proxy(url, fetch(url)).then((resp) => {
    if (resp.code === 0 && resp.data && resp.data.list) {
        this.setState({
            list: resp.data.list
        })
    }
}).catch(err => console.error(err));
```

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