decorator-memoize-one
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

Decorator Memoize One

NPM version NPM downloads Build status Test coverage

Simple decorator for caching the result of a function based on the most recent arguments.

Installation

npm install decorator-memoize-one --save

Usage

import { memoizeOne } from "decorator-memoize-one";
import { pool } from "./db";
 
class User {
  @memoizeOne
  friends(pool) {
    return pool.execute("SELECT * FROM users WHERE ...");
  }
}
 
const user = new User();
const friends = await user.friends(pool);

License

MIT

Package Sidebar

Install

npm i decorator-memoize-one

Weekly Downloads

2

Version

1.0.2

License

MIT

Unpacked Size

13.3 kB

Total Files

9

Last publish

Collaborators

  • blakeembrey