@code-workers.io/ts-memoize
v1.0.2
Published
A lightweight utility library to memoize function calls
Downloads
3
Maintainers
Readme
@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);
}
}