Options
All
  • Public
  • Public/Protected
  • All
Menu

Module Utils

A core namespace which contains utility methods for general purpose operations and more specialized utility sub-modules.

Index

Variables

Types

Types: object

An enumeration containing strings that represent the actual type of an object.

Type declaration

  • Array: string

    Returns "[object Array]".

  • Boolean: string

    Returns "[object Boolean]".

  • Date: string

    Returns "[object Date]".

  • Function: string

    Returns "[object Function]".

  • Null: string

    Returns "[object Null]".

  • Number: string

    Returns "[object Number]".

  • Object: string

    Returns "[object Object]".

  • RegExp: string

    Returns "[object RegExp]".

  • String: string

    Returns "[object String]".

  • Undefined: string

    Returns "[object Undefined]".

Private isArray

isArray: isArray

Functions

Private canDeepMerge

  • canDeepMerge(copy: Indexable<Object>, context: RecursiveContext): boolean

clone

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

    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

Private createCloneFunction

  • createCloneFunction(cloneFunc: function): (Anonymous function)
  • Parameters

    • cloneFunc: function
        • (object: Object, deep?: boolean, objectIsArray?: boolean): Object
        • Parameters

          • object: Object
          • Optional deep: boolean
          • Optional objectIsArray: boolean

          Returns Object

    Returns (Anonymous function)

Private createExtendObject

  • createExtendObject(object: Object, objectIsArray: boolean): Object

Private createRemoveFunction

  • createRemoveFunction(predicateKey?: Object): (Anonymous function)

deepExtend

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

    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

Private deepMerge

  • deepMerge(target: Indexable<Object>, copy: Indexable<Object>, context: RecursiveContext): void

extend

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

    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.

    Type parameters

    • T

      The type of the cloned object.

    Parameters

    • object: T

      The data object to clone.

    Returns T

Private fillTypes

  • fillTypes<T>(types: T): T

Private getDeepMergeSource

Private getDeepTarget

getType

  • getType(object: Object): string
  • Returns the actual type of an object (unlike typeof), see Types.

    Parameters

    • object: Object

      The object to test.

    Returns string

Private getTypeString

  • getTypeString(type: string): string

Private innerExtend

  • innerExtend(target: Indexable<Object>, objects: Indexable<Object>[], context: RecursiveContext): Object

Private innerRemoveProperty

  • innerRemoveProperty(object: Indexable<Object>, context: RemovePropertyContext): void

isEmpty

  • isEmpty(object: Object): boolean
  • Returns true if an object is empty (contains no enumerable properties).

    Parameters

    • object: Object

      The object to test.

    Returns boolean

Private isEnumerable

  • isEnumerable(object: Object): boolean

isObject

  • isObject(object: Object): boolean
  • Returns true if an object is an object instance with language type of [[Types.Object]].

    Parameters

    • object: Object

      The object to test.

    Returns boolean

isType

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

    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.

    Type parameters

    • T

      The type of object to update.

    Parameters

    • object: T

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

    Returns T

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

Private merge

  • merge(target: Indexable<Object>, object: Indexable<Object>, context: RecursiveContext): void

removeEmpty

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

    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).

    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.

Private removeProperty

  • removeProperty(object: Indexable<Object>, context: RemovePropertyContext): Array<Object> | Indexable<Object>

removeUndefined

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

    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.

Private validateValueAsKey

  • validateValueAsKey<T>(object: T, result: T, value: string): void

Object literals

Private removePredicates

removePredicates: object
  • (value: Object): boolean

0

  • 0(value: Object): boolean

undefined

  • undefined(value: Object): boolean

Generated using TypeDoc