# memoized-class-decorator

> Minimalistic memoization decorator

Latest version **1.6.1** (published 2018-03-08) · Unlicense license · 0 weekly downloads

## Install

```sh
npm install memoized-class-decorator
pnpm add memoized-class-decorator
yarn add memoized-class-decorator
bun add memoized-class-decorator
```

## 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.6.1 |
| Published | 2018-03-08 |
| First published | 2017-02-01 |
| Weekly downloads | 0 |
| License | Unlicense |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Mark Kahn |
| Maintainers | linusnorton |
| Keywords | memoize, decorator, memoization, es6, es7, classes |

## Links

- npm: https://www.npmjs.com/package/memoized-class-decorator
- Repository: https://github.com/open-track/memoized-decorator
- Homepage: https://github.com/open-track/memoized-decorator#readme
- Issues: https://github.com/open-track/memoized-decorator/issues
- npm.io page: https://npm.io/package/memoized-class-decorator

## Alternatives

- [localforage](https://npm.io/package/localforage.md) — 6.2M weekly downloads
- [localforage-observable](https://npm.io/package/localforage-observable.md) — 30.8K weekly downloads
- [@y/y](https://npm.io/package/@y/y.md) — 30.1K weekly downloads
- [@metaobjectsdev/render](https://npm.io/package/@metaobjectsdev/render.md) — 3.5K weekly downloads
- [@ledgerhq/coin-algorand](https://npm.io/package/@ledgerhq/coin-algorand.md) — 1.1K weekly downloads

## Recent versions

- 1.6.1 (latest) — 2018-03-08
- 1.6.0 — 2018-03-08
- 1.5.0 — 2017-10-06
- 1.4.0 — 2017-09-29
- 1.3.0 — 2017-09-12
- 1.2.0 — 2017-05-23
- 1.1.0 — 2017-05-10
- 1.0.1 — 2017-02-03
- 1.0.0 — 2017-02-01

## README

# Memoized Decorator

A fork of [memoized-decorator](https://github.com/VoiceNGO/memoized-decorator) that takes class properties into consideration by attaching the memoization cache at the object level rather than class level. 

Serializes arguments by `.toString()` or `JSON.strinigify` for objects literals
  & arrays.  `null` & `undefined` safe.

## Installation

```sh
npm install --save memoized-class-decorator
```

## Usage

```typescript
import memoize = require('memoized-class-decorator');

class Foo {

  constructor(private readonly num: number) { }

  @memoize
  public myMethod(add: number) {
    return this.num + add;
  }
}

const f1 = new Foo(5);

f1.myMethod(5);  //= 10 (method is invoked)
f1.myMethod(10); //= 15 (method is invoked)
f1.myMethod(5);  //= 10 (method is not invoked)

const f2 = new Foo(0);

f2.myMethod(5);  //= 5 (method is invoked, each object has it's own cache)

```

Note that if an object is passed to the method with an `id` property, the value of that propery will be used as the cache key. This is to reduce the time needed to serialize complex objects.

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