# fast-cache

> Caches a method that returns a promise and does so really fast.

Latest version **1.1.1** (published 2016-12-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install fast-cache
pnpm add fast-cache
yarn add fast-cache
bun add fast-cache
```

## 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.1.1 |
| Published | 2016-12-31 |
| First published | 2016-07-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | David Björklund |
| Maintainers | kesla |

## Links

- npm: https://www.npmjs.com/package/fast-cache
- Repository: https://github.com/kesla/fast-cache
- Homepage: https://github.com/kesla/fast-cache#readme
- Issues: https://github.com/kesla/fast-cache/issues
- npm.io page: https://npm.io/package/fast-cache

## Recent versions

- 1.1.1 (latest) — 2016-12-31
- 1.1.0 — 2016-07-21
- 1.0.0 — 2016-07-21

## README

# fast-cache 

Caches a method that returns a promise and does so really fast.

## Installation

Download node at [nodejs.org](http://nodejs.org) and install it, if you haven't already.

```sh
npm install fast-cache --save
```

## Usage

```js
/* eslint-disable */

import fastCache from 'fast-cache';
import { keyCache } from 'fast-cache';

// this will only be called once since it'll get cached
const fn = () => {
  // fetch is just an example, could be something so simple as Promise.resolve(...)
  return fetch('http://example.com')
    .then(response => response.json());
};
const cached = fastCache(fn);

cached().then((json) => {
  console.log('json1', json);
});

cached().then((json) => {
  console.log('json2', json);
});

const keyBased = keyCache((id) => {
  // again, this is just an example. just needs to be something returning a promise
  return fetch(`http://example.com/${id}`);
});

keyBased('id1').then((response) => {
  console.log('id1 response', response);
});

keyBased('id2').then((response) => {
  console.log('different response from id1', response);
});

```

## Tests

```sh
npm install
npm test
```

## Dependencies

None

## Dev Dependencies

- [async-cache-promise](https://github.com/kesla/async-cache-promise): async-cache - but with promises
- [babel-cli](https://github.com/babel/babel/tree/master/packages): Babel command line.
- [babel-core](https://github.com/babel/babel/tree/master/packages): Babel compiler core.
- [babel-plugin-syntax-async-functions](https://github.com/babel/babel/tree/master/packages): Allow parsing of async functions
- [babel-plugin-transform-async-to-generator](https://github.com/babel/babel/tree/master/packages): Turn async functions into ES2015 generators
- [babel-polyfill](https://github.com/babel/babel/tree/master/packages): Provides polyfills necessary for a full ES2015+ environment
- [babel-preset-es2015](https://github.com/babel/babel/tree/master/packages): Babel preset for all es2015 plugins.
- [babel-tape-runner](https://github.com/wavded/babel-tape-runner): Babel + Tape for running your ES Next tests
- [miclint](https://github.com/micnews/miclint): mic lint cli
- [package-json-to-readme](https://github.com/zeke/package-json-to-readme): Generate a README.md from package.json contents
- [tapava](https://github.com/kesla/tapava): the syntax of ava, run through tape


## License

MIT

_Generated by [package-json-to-readme](https://github.com/zeke/package-json-to-readme)_

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