1.0.2 • Published 5 years ago

decorator-memoize-one v1.0.2

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

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