import { memoized } from "https://deno.land/x/911@0.1.1/src/memoize.ts";
TypeScript Decorator to memoize a function. Accepts same options as memoize.
Examples
Example 1
Example 1
import { memoized } from "https://deno.land/x/911@0.1.1/src/memoize.ts";
const cache = new Map();
class MyClass {
// The quotes are to stop JSDoc from breaking on the "@".
// You should not use quotes in your actual code.
"@memoized"({ cache })
public myMethod() {
return Promise.resolve(1);
}
}
Parameters
optional
options: MemoizeOptions<A, R> = [UNSUPPORTED]Define your own cache or hash function (both optional).