# bm-better-memoization

> easily wrap functions in a caching layer

Latest version **1.0.1** (published 2018-07-19) · ISC license · 0 weekly downloads

## Install

```sh
npm install bm-better-memoization
pnpm add bm-better-memoization
yarn add bm-better-memoization
bun add bm-better-memoization
```

## 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.1 |
| Published | 2018-07-19 |
| First published | 2018-04-15 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | mahhov |
| Maintainers | mahhov |
| Keywords | function, caching, memoization, better |

## Links

- npm: https://www.npmjs.com/package/bm-better-memoization
- Repository: https://github.com/mahhov/function-caching
- Homepage: https://github.com/mahhov/function-caching#readme
- Issues: https://github.com/mahhov/function-caching/issues
- npm.io page: https://npm.io/package/bm-better-memoization

## Recent versions

- 1.0.1 (latest) — 2018-07-19
- 1.0.0 — 2018-07-19
- 0.0.1 — 2018-04-15

## README

# Overview

Wraps a function with a memoized function

### setup

`npm i -save bm-better-memoization`

`const m3m = require('bm-better-memoization');`

# Basic Example

### our functions

```
let sum = (a, b) => ({sum: a + b});
let sum$ = m3m(sum);
```

### using un-memoized function

```
let sum1 = sum(10, 3);
let sum2 = sum(10, 3);
// sum1 !== sum2;
```

### using memoized function

```
let sum$1 = sum$(10, 3);
let sum$2 = sum$(10, 3);
// sum$1 === sum$2;
```

### parameters

```
let thirteen = sum$(10, 3);
let five = sum$(2, 3);
let eleven = sum$(10, 1);
let elevenAgain = sum$(1, 10);
// thirteen !== five !== eleven !== elevenAgain
```

### clearing cache

```
let four = sum$(2, 2);
let fourAgain = sum$(2, 2);
sum$.clear();
let fourAfter = sum$(2, 2);
let fourAfterAgain = sum$(2, 2);
// (four === fourAgain) !== (fourAfter === fourAfterAgain)
```


<br><br><sub><sub>this markdown was generated by [de-document-examples](https://www.npmjs.com/package/de-document-examples)</sub></sub>

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