Options
All
  • Public
  • Public/Protected
  • All
Menu

Module Config

An optional sub-module which contains various configurational methods.

All methods can be chained like Format.Config.addFormatToPrototype().addUtilsToGlobals()...

Index

Functions

addFormatToPrototype

  • addFormatToPrototype(): Config
  • Adds the String.format function, which allows for direct instance calls like "{0}".format(val1, val2, ...).

    If the first argument of such calls is an object that implements the FormatProvider interface (or more precisely has a method getFormatter):

    • It will be used to create the formatting context (same behaviour as with normal StringConstructor.format overloads)
    • The trailing arguments will be used as replacement values starting from 0

    Returns Config

addPaddingToPrototype

  • addPaddingToPrototype(): Config

addToPrototype

  • addToPrototype(bareFunction: Function, hostObject: Object, name?: string): Config
  • Adds a bare function (one that does not rely on any local this context) to the host object's prototype.

    Parameters

    • bareFunction: Function

      A function the first argument of which can be replaced by the this context of the host object.

    • hostObject: Object

      A host object (usually a constructor function) the prototype of which will be updated to contain the wrapped bare function.

    • Optional name: string

      The name of the new prototype method which is added, defaults to the bare function's name. Required if the bare function is anonymous.

    Returns Config

addToStringOverload

  • addToStringOverload(): Config
  • Adds the Number.toString and Date.toString overloads while retaining the original toString behaviour if those overloads are not matched by the supplied parameters.

    For example (12).toString(2) === "1100" but (12).toString("2") === String.format("{0:2}", 12) because it matches the format string overload.

    Returns Config

addUtilsToGlobals

  • addUtilsToGlobals(): Config

addUtilsToPrototype

  • addUtilsToPrototype(): Config

disableMemoization

  • disableMemoization(): Config
  • Disables performance improvements through memoization of key inner functions and releases the used memory.

    Returns Config

enableMemoization

  • enableMemoization(): Config
  • Enables performance improvements through memoization of key inner functions at the cost of memory.

    Returns Config

removeFormatFromPrototype

  • removeFormatFromPrototype(): Config

removePaddingFromPrototype

  • removePaddingFromPrototype(): Config

removeToStringOverload

  • removeToStringOverload(): Config

removeUtilGlobals

  • removeUtilGlobals(): Config

removeUtilsFromPrototype

  • removeUtilsFromPrototype(): Config

Generated using TypeDoc