# @uppercod/cache

> This script creates an in-memory cache

Latest version **1.1.0** (published 2020-09-22) · ISC license · 0 weekly downloads

## Install

```sh
npm install @uppercod/cache
pnpm add @uppercod/cache
yarn add @uppercod/cache
bun add @uppercod/cache
```

## Health

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

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

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2020-09-22 |
| First published | 2020-08-18 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 14.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | UpperCod |
| Maintainers | uppercod |

## Links

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

## Dependencies (1)

- [resolve-css](https://npm.io/package/resolve-css.md) ^1.0.0

## Recent versions

- 1.1.0 (latest) — 2020-09-22
- 1.0.0 — 2020-08-18

## README

# cache

This script creates an in-memory cache that allows:

1. The callback execution when regenerating the arguments.
2. Use references to return arguments.

## install

```
npm install cache
```

## Usage

Suppose that part was a high-cost process, such as template rendering or an asynchronous call.

```js
import createCache from "@uppercod/cache";

const cache = createCache();

function parse(code = "") {
    return code.split(/ */);
}
/**
 * the Cache function will only memorize the first execution, since there is no second parameter.
 */
const value1 = cache(parse);
/**
 * The cache function will memorize the execution of the function based on the second parameter.
 **/
const value2 = cache(parse, "my-code");
/**
 * The cache function memorizes the execution of the function based on the arguments of the second parameter.
 **/
const value3 = cache(parse, ["my-code"]);
```

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