Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andreypopp/memoize-decorator
Memoize getters and methods to compute only once
https://github.com/andreypopp/memoize-decorator
Last synced: about 2 months ago
JSON representation
Memoize getters and methods to compute only once
- Host: GitHub
- URL: https://github.com/andreypopp/memoize-decorator
- Owner: andreypopp
- License: mit
- Created: 2015-04-11T12:26:26.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2022-01-10T11:34:39.000Z (almost 3 years ago)
- Last Synced: 2024-10-05T13:57:04.655Z (2 months ago)
- Language: JavaScript
- Homepage:
- Size: 7.81 KB
- Stars: 30
- Watchers: 3
- Forks: 6
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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](http://babeljs.io).Installation:
% npm install memoize-decorator
Example:
```js
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
```