1.0.2 • Published 1 year ago

@code-workers.io/ts-memoize v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@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);
  }
}