Options
All
  • Public
  • Public/Protected
  • All
Menu

Module Function

A Format.Utils sub-module containing methods related to functional operations.

Index

Variables

Private returnNameRegExp

returnNameRegExp: RegExp

Private typeNameRegExp

typeNameRegExp: RegExp

Functions

Private empty

  • empty<T>(): T

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.

    Type parameters

    • T

      The return type of the empty callback.

    Returns function

      • (): T
      • Returns T

getName

  • getName(func: Function): string
  • Returns the name of a function.

    Parameters

    • func: Function

      A functional object.

    Returns string

    The name of a function or "" for lambda functions.

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.

    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 load the Format.Config sub-module 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

Private validateFunctionArgument

  • validateFunctionArgument(func: Function, methodName: string): void

Generated using TypeDoc