Library API
    Preparing search index...

    Function memoizeMethod

    • Defines a PropertyDescriptor for an object's memoized method. Caches the results of method calls on a per-instance basis.

      Type Parameters

      Parameters

      • name: PropertyKey

        The name of the method

      • fn: (this: Context, ...args: any[]) => T

        The method implementation

      Returns PropertyDescriptor

      A PropertyDescriptor containing the memoization logic

      Object.defineProperty(target, 'calc', memoizeMethod('calc', () => 42));