Class FunctionUtil

Function utilities

Hierarchy

  • FunctionUtil

Constructors

Methods

  • Buffer the function with this number of milliseconds. When the function is called multiple times within the delay period only the last call will execute.

    Parameters

    • delay: number
    • fn: Function

    Returns ((...args) => Promise<unknown>)

      • (...args): Promise<unknown>
      • Parameters

        • Rest ...args: any[]

        Returns Promise<unknown>

  • Create a combined function of an orignal and new function. The new function will be called before the original,

    Type Parameters

    • F extends Func

    Parameters

    • origFn: F
    • newFn: ((...args) => unknown)
        • (...args): unknown
        • Parameters

          • Rest ...args: Parameters<F>

          Returns unknown

    Returns F

    Example

    export function playgroundTableOverride() {
    PlaygroundTable.prototype.render = FunctionUtil.createInterceptor(
    PlaygroundTable.prototype.render,
    function(this:PlaygroundTable) {
    this.el.classList.add("cls-added-by-override");
    }
    )
    }
  • Will combine the given functions into one.

    The newFn function will be called with the return value of origFn function + the parameters of origFn and function will return the value of newFn

    Type Parameters

    • F extends Func

    Parameters

    • origFn: F
    • newFn: ((retVal, ...args) => unknown)
        • (retVal, ...args): unknown
        • Parameters

          • retVal: ReturnType<F>
          • Rest ...args: Parameters<F>

          Returns unknown

    Returns F

    Example

    function test(a:number, b:string) : string {
    return b;
    }

    FunctionUtil.createSequence(test, function(r, a, b) {
    return r + "b";
    })
  • Delay function execution

    Parameters

    • delay: number
    • fn: Function

    Returns ((...args) => void)

      • (...args): void
      • Parameters

        • Rest ...args: any[]

        Returns void

Generated using TypeDoc