Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface FunctionConstructor

Extends the built-in javascript Function object's static API.

The Format.Config.addUtilsToGlobals method must be called in order to access the definitions.

Hierarchy

  • FunctionConstructor

Index

Methods

getEmpty

  • getEmpty<T>(): function
  • Returns an empty parameterless function which returns undefined. Useful for defaulting optional callback arguments instead of creating new anonymous empty functions.

    Must call Format.Config.addUtilsToGlobals to be defined.

    Type parameters

    • T

      The return type of the empty callback.

    Returns function

      • (): T
      • Returns T

getName

  • getName(func: Function): string

getReturnName

  • getReturnName(func: Function): string
  • Returns the rightmost accessor's name of the function's first returned variable.

    For example a return expression like return this.field; will yield "field" as a value.

    Must call Format.Config.addUtilsToGlobals to be defined.

    Parameters

    • func: Function

      A functional object.

    Returns string

    The text of the last literal contained in the first return expression of the function.

memoize

  • memoize<T>(func: T, resolver?: function): T
  • Returns a memoized function wrapper of the function. All calls with the same arguments to the original function are cached after the first use.

    Must call Format.Config.addUtilsToGlobals to be defined.

    Type parameters

    • T: Function

      The type/signature of the original function.

    Parameters

    • func: T

      The function whose results will be cached.

    • Optional resolver: function

      A cache key resolver function used to store the call arguments' list as a string key. Defaults to JSON.stringify.

        • (argumentValues: Object[]): string
        • Parameters

          • argumentValues: Object[]

            An array containing the call arguments for the function.

          Returns string

    Returns T

Generated using TypeDoc