memoize-decorator

1.0.2 • Public • Published

memoize decorator

This is a method/getter decorator which is when applied to a method or a getter memoizes the result of the first call and returns it on subsequent calls.

As decorators are a part of future ES7 standard they can only be used with transpilers such as Babel.

Installation:

% npm install memoize-decorator

Example:

import memoize from 'memoize-decorator'

class Component {

  @memoize
  get expensiveValue() {
    console.log('heavy computations')
    return 42
  }
}

let component = new Component()
component.expensiveValue // prints 'heavy computations', returns 42
component.expensiveValue // just returns 42

Readme

Keywords

none

Package Sidebar

Install

npm i memoize-decorator

Weekly Downloads

18,274

Version

1.0.2

License

MIT

Last publish

Collaborators

  • andreypopp