decorator-memoize-one
v1.0.2
Published
Simple decorator for caching the result of a function based on the most recent arguments
Downloads
9
Maintainers
Readme
Decorator Memoize One
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