# mag-data-cacher

> Caches data in a predetermined range.

Latest version **1.0.7** (published 2019-03-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install mag-data-cacher
pnpm add mag-data-cacher
yarn add mag-data-cacher
bun add mag-data-cacher
```

## 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.7 |
| Published | 2019-03-15 |
| First published | 2017-04-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 20.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Stoian Roman |
| Maintainers | magsdk |
| Keywords | mag, sdk, magsdk, framework, data, cacher |

## Links

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

## Dependencies (1)

- [stb-keys](https://npm.io/package/stb-keys.md) ^1.4.4

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 1.0.7 (latest) — 2019-03-15
- 1.0.6 — 2018-10-26
- 1.0.5 — 2018-09-26
- 1.0.4 — 2018-08-14
- 1.0.2 — 2017-10-17
- 1.0.1 — 2017-04-28

## README

Data Cacher
===========

[![build status](https://img.shields.io/travis/magsdk/data-cacher.svg?style=flat-square)](https://travis-ci.org/magsdk/data-cacher)
[![npm version](https://img.shields.io/npm/v/mag-data-cacher.svg?style=flat-square)](https://www.npmjs.com/package/mag-data-cacher)
[![dependencies status](https://img.shields.io/david/magsdk/data-cacher.svg?style=flat-square)](https://david-dm.org/magsdk/data-cacher)
[![devDependencies status](https://img.shields.io/david/dev/magsdk/data-cacher.svg?style=flat-square)](https://david-dm.org/magsdk/data-cacher?type=dev)
[![Gitter](https://img.shields.io/badge/gitter-join%20chat-blue.svg?style=flat-square)](https://gitter.im/DarkPark/magsdk)


Caches data in a predetermined range.


## Installation ##

```bash
npm install mag-data-cacher
```


## Usage ##

Add the constructor to the scope:

```js
var DataCacher = require('mag-data-cacher');
```

Create instance with custom config:

```js
var dataCacher = new DataCacher({
        pageSize: 7,
        cacheSize: 2,
        request: {},
        getter: function ( callback, config, count ) {
            //
        }
    });
```

To check and get data for next page:

```js
var callback = function ( error, receivedData ) {
    console.log(error);
    console.log(receivedData);
};

dataCacher.checkPrev(callback);
```

To check and get data for previous page:

```js
dataCacher.checkNext(callback);
```

To check and get data for 1st page:

```js
dataCacher.goHome(callback);
```

To check and get data for last page:

```js
dataCacher.goEnd(callback);
```

To refresh data:

```js
dataCacher.refreshData(callback);
```

## Contribution ##

If you have any problems or suggestions please open an [issue](https://github.com/magsdk/data-cacher/issues)
according to the contribution [rules](.github/contributing.md).


## License ##

`mag-data-cacher` is released under the [MIT License](license.md).

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