https://github.com/blakeembrey/decorator-cache-getter
Simple decorator for caching getters on first access
https://github.com/blakeembrey/decorator-cache-getter
cache getter memoize typescript
Last synced: 8 months ago
JSON representation
Simple decorator for caching getters on first access
- Host: GitHub
- URL: https://github.com/blakeembrey/decorator-cache-getter
- Owner: blakeembrey
- License: mit
- Created: 2019-01-21T21:53:26.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2025-07-22T12:56:31.000Z (11 months ago)
- Last Synced: 2025-09-18T10:59:47.649Z (9 months ago)
- Topics: cache, getter, memoize, typescript
- Language: TypeScript
- Size: 916 KB
- Stars: 13
- Watchers: 2
- Forks: 4
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# Decorator Cache Getter
[![NPM version][npm-image]][npm-url]
[![NPM downloads][downloads-image]][downloads-url]
[![Build status][travis-image]][travis-url]
[![Test coverage][coveralls-image]][coveralls-url]
> Simple decorator for caching getters on first access.
## Installation
```sh
npm install decorator-cache-getter --save
```
## Usage
```js
import { cache } from "decorator-cache-getter";
class User {
@cache
get friends() {
return sql("SELECT * FROM users WHERE ...")
}
}
const user = new User()
const friends = await user.friends;
```
## License
MIT
[npm-image]: https://img.shields.io/npm/v/decorator-cache-getter.svg?style=flat
[npm-url]: https://npmjs.org/package/decorator-cache-getter
[downloads-image]: https://img.shields.io/npm/dm/decorator-cache-getter.svg?style=flat
[downloads-url]: https://npmjs.org/package/decorator-cache-getter
[travis-image]: https://img.shields.io/travis/blakeembrey/decorator-cache-getter.svg?style=flat
[travis-url]: https://travis-ci.org/blakeembrey/decorator-cache-getter
[coveralls-image]: https://img.shields.io/coveralls/blakeembrey/decorator-cache-getter.svg?style=flat
[coveralls-url]: https://coveralls.io/r/blakeembrey/decorator-cache-getter?branch=master