Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface ObjectConstructor

Extends the built-in javascript Object static API.

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

Hierarchy

  • ObjectConstructor

Index

Methods

clone

  • clone<T>(object: T, deep?: boolean): T
  • Creates a new object that is a shallow or deep copy of the current instance.

    Must call Format.Config.addUtilsToGlobals to be defined.

    Type parameters

    • T

      The type of the cloned object.

    Parameters

    • object: T

      The object to clone.

    • Optional deep: boolean

      A flag specifying whether the result should be a deep copy or not.

    Returns T

deepExtend

  • deepExtend<T>(target: T, object: Object, ...objects: Object[]): T
  • Recursivelly merge the contents of two or more objects together into the first object.

    Must call Format.Config.addUtilsToGlobals to be defined.

    Type parameters

    • T

      The type of the object to merge into.

    Parameters

    • target: T

      An object that will receive the new properties.

    • object: Object

      An object containing additional properties to merge in.

    • Rest ...objects: Object[]

      A list of arguments that consists of more objects that contain additional properties to merge in.

    Returns T

extend

  • extend<T>(target: T, object: Object, ...objects: Object[]): T
  • Merge the contents of two or more objects together into the first object.

    Must call Format.Config.addUtilsToGlobals to be defined.

    Type parameters

    • T

      The type of the object to merge into.

    Parameters

    • target: T

      An object that will receive the new properties.

    • object: Object

      An object containing additional properties to merge in.

    • Rest ...objects: Object[]

      A list of arguments that consists of more objects that contain additional properties to merge in.

    Returns T

fastClone

  • fastClone<T>(object: T): T
  • Creates a new data object that is a deep data copy of the current instance.

    Non-data property values (functions or undefined) are NOT copied. In arrays any non-copy value is left as null so as to preserve the original indexing.

    Must call Format.Config.addUtilsToGlobals to be defined.

    Type parameters

    • T

      The type of the cloned object.

    Parameters

    • object: T

      The data object to clone.

    Returns T

getType

  • getType(object: Object): string

isEmpty

  • isEmpty(object: Object): boolean

isObject

  • isObject(object: Object): boolean

isType

  • isType(type: string, object: Object): boolean
  • Returns true if an object's type matches the given type argument.

    Must call Format.Config.addUtilsToGlobals to be defined.

    Parameters

    • type: string

      A string indicating the expected type of the object, i.e. "Array", "RegExp", etc.

    • object: Object

      The object to check for matching type.

    Returns boolean

mapValuesAsKeys

  • mapValuesAsKeys<T>(object: T): T
  • Maps the given object's values as keys with their keys as values and returns the extended object.

    Throws an error if the operation results in key duplication or keys with 'undefined' or 'null' values.

    Must call Format.Config.addUtilsToGlobals to be defined.

    Type parameters

    • T

      The type of object to update.

    Parameters

    • object: T

      The object to fill with the mapped unique values as keys.

    Returns T

    A new object with all of the original and inverted properties.

removeEmpty

  • removeEmpty<T>(object: T, deep?: boolean): T
  • Removes all properties with null, undefined or "" values.

    Must call Format.Config.addUtilsToGlobals to be defined.

    Type parameters

    • T

      The type of the object to remove from.

    Parameters

    • object: T

      The object to remove from.

    • Optional deep: boolean

      Optional flag specifying whether the removal should be recursive.

    Returns T

    The same object instance without null, undefined or "" elements.

removeFalsy

  • removeFalsy<T>(object: T, deep?: boolean): T
  • Removes all properties with falsy values (null, undefined, "" or 0).

    Must call Format.Config.addUtilsToGlobals to be defined.

    Type parameters

    • T

      The type of the object to remove from.

    Parameters

    • object: T

      The object to remove from.

    • Optional deep: boolean

      Optional flag specifying whether the removal should be recursive.

    Returns T

    The same object instance without falsy elements.

removeUndefined

  • removeUndefined<T>(object: T, deep?: boolean): T
  • Removes all properties with null or undefined values.

    Must call Format.Config.addUtilsToGlobals to be defined.

    Type parameters

    • T

      The type of the object to remove from.

    Parameters

    • object: T

      The object to remove from.

    • Optional deep: boolean

      Optional flag specifying whether the removal should be recursive.

    Returns T

    The same object instance without null or undefined elements.

Generated using TypeDoc