Skip to content

A utility library to memoize function calls in TypeScript

Notifications You must be signed in to change notification settings

code-workers-io/ts-memoize

Repository files navigation

@code-workers.io/ts-memoize

Library providing memoization functionality via:

  • a memoize-function
  • a Memoize-decorator

Installation

npm i @code-workers.io/ts-memoize

Usage

Decorator Usage

Annotate the function you want to memoize using the Memoize-decorator:

class Test {
  @Memoize()
  calculate(a: number, b: number): number {
    return a + b;
  }
}

Function usage

Use the memoize-function:

class Test {
  calc(a: number, b: number): number {
    return memoize((a, b) => a + b).memoized(a, b);
  }
}

About

A utility library to memoize function calls in TypeScript

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published