Skip to content
This repository was archived by the owner on Jun 22, 2024. It is now read-only.

abeluzhenko/memoza

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Memoza

Memoizing TypeScript decorator

Replaces a method with its memoized version. Adds a memoization by:

  • input arguments;
  • dependencies (current class fields);

Installation

$ yarn add memoza

or

$ npm install memoza

Usage

import { Memoized } from 'memoza';

class Something {
  public title = 'Title';
  public isFlagA = true;
  public isFlagB = false;

  /* Memoize by dependencies and arguments */
  @Memoized<Something>('isFlagA', 'isFlagB')
  public isBothAnB() {
    return this.valueA && this.valueB;
  }

  /* Memoize by arguments only */
  @Memoized()
  public getTitle(roundNum: number) {
    return `Title ${roundNum}`;
  }
}

About

Typescript method memoization decorator

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors