memoize-decorator
Memoize getters and methods to compute only once
Last updated 12 years ago by andreypopp .
MIT · Original npm · Tarball · package.json
$ npm install memoize-decorator 
SYNC missed versions from official npm registry.

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

Current Tags

  • 1.0.2                                ...           latest (12 years ago)

3 Versions

  • 1.0.2                                ...           12 years ago
  • 1.0.1                                ...           12 years ago
  • 1.0.0                                ...           12 years ago
Maintainers (1)
Downloads
Total 6
Today 0
This Week 0
This Month 4
Last Day 0
Last Week 2
Last Month 1
Dependencies (0)
None
Dev Dependencies (5)
Dependents (0)
None

© 2010 - cnpmjs.org x YWFE | Home | YWFE