Skip to content

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

License

Notifications You must be signed in to change notification settings

blakeembrey/decorator-memoize-one

Repository files navigation

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

About

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

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published