# @tyimarques/memo

> Caches function output with separated cache for each input signature

Latest version **1.1.5** (published 2021-02-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install @tyimarques/memo
pnpm add @tyimarques/memo
yarn add @tyimarques/memo
bun add @tyimarques/memo
```

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.5 |
| Published | 2021-02-06 |
| First published | 2021-01-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Tiago Marques |
| Maintainers | tyimarques |
| Keywords | memo, cache, function, utilities |

## Links

- npm: https://www.npmjs.com/package/@tyimarques/memo
- Repository: https://github.com/timarques/memo
- Homepage: https://github.com/timarques/memo#readme
- Issues: https://github.com/timarques/memo/issues
- npm.io page: https://npm.io/package/@tyimarques/memo

## 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.1.5 (latest) — 2021-02-06
- 1.1.4 — 2021-02-06
- 1.1.3 — 2021-02-06
- 1.1.2 — 2021-02-06
- 1.1.1 — 2021-01-29
- 1.1.0 — 2021-01-29

## README

# memo
Caches function output with separated cache for each input signature

## Table of Contents

- [Installation](#installation)
- [Usage](#usage)
- [License](#License)

## Installation

```npm i @tyimarques/memo```

## Usage
```js
import memo from "@tyimarques/memo";
const callback = () => true;
const memoizedCallback = memo(callback);
memoizedCallback() //not cached
memoizedCallback() //cached

const evenAnotherMemoizedCallback = memo(callback, { duration: 100 })
evenAnotherMemoizedCallback() // not cached
evenAnotherMemoizedCallback() // cached
setTimeout(() => {
    evenAnotherMemoizedCallback() // not cached
}, 100)

const anotherCallback = (first, second, thrid) => first + second + third
const anotherMemoizedCallback = memo(anotherCallback)
anotherMemoizedCallback(1, 2, 3) // 6, not cached
anotherMemoizedCallback(1, 2, 3) // 6, cached
anotherMemoizedCallback(2, 2, 3) // 7, not cached
```

## License
[MIT](license)

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