@typescript-plus/fast-memoize-decorator
TypeScript icon, indicating that this package has built-in type declarations

0.2.1 • Public • Published

fast-memoize Decorator

A TypeScript decorator for memoizing properties using fast-memoize.

CircleCI

Install

$ npm i @typescript-plus/fast-memoize-decorator --save

Usage

import { Memoize } from '@typescript-plus/fast-memoize-decorator';

class Tomorrow {
  @Memoize() when(today: Date) {
    console.log('compute!');
    const date = new Date(today.getTime());
    date.setDate(date.getDate() + 1);
    return date;
  }
}

const tomorrow = new Tomorrow();

// returns 2nd Apr. 2000 and prints "compute!"
tomorrow.when(new Date(2000, 4, 1));

// returns 2nd Apr. 2000 and prints nothing
tomorrow.when(new Date(2000, 4, 1));

// returns 3rd Apr. 2000 and prints "compute!"
tomorrow.when(new Date(2000, 4, 2));

LICENSE

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i @typescript-plus/fast-memoize-decorator

Weekly Downloads

5,584

Version

0.2.1

License

MIT

Unpacked Size

4.8 kB

Total Files

6

Last publish

Collaborators

  • mosop