Skip to content

andreypopp/memoize-decorator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Memoize getters and methods to compute only once

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •