MCPcopy Index your code
hub / github.com/TypeScriptToLua/TypeScriptToLua / memoize

Function memoize

test/util.ts:95–104  ·  view source on GitHub ↗
(originalFunction: any)

Source from the content-addressed store, hash-verified

93}
94
95const memoize = (originalFunction: any) => {
96 const memoized = new WeakMap();
97 return function (this: any, ...args: any[]): any {
98 if (!memoized.has(this)) {
99 memoized.set(this, originalFunction.apply(this, args));
100 }
101
102 return memoized.get(this);
103 };
104};
105
106export class ExecutionError extends Error {
107 public name = "ExecutionError";

Callers

nothing calls this directly

Calls 3

hasMethod · 0.95
setMethod · 0.95
getMethod · 0.95

Tested by

no test coverage detected