Options
All
  • Public
  • Public/Protected
  • All
Menu

Utilities to perform common object operations

Hierarchy

  • ObjectUtils

Index

Methods

Static apply

  • apply(object: any, callableFunction: (v: any) => any): any
  • Apply a given function to each value of the provided object (Recursively through all the object elements). It will also scan inside arrays and sub objects.

    NOTICE: Original object is not modified

    Parameters

    • object: any

      Any language instance like numbers, strings, arrays, objects, etc.. that we want to process.

    • callableFunction: (v: any) => any

      A function that takes a single argument and returns a value. It must always return a value, cause it will be assigned to the original object

        • (v: any): any
        • Parameters

          • v: any

          Returns any

    Returns any

    An exact independent copy of the received object, without any shared reference, where each value has been processed by the provided callable function.

Static clone

  • clone(object: any): any
  • Perform a deep copy of the given object.

    Parameters

    • object: any

      Any language instance like numbers, strings, arrays, objects, etc.. that we want to duplicate.

    Returns any

    An exact independent copy of the received object, without any shared reference.

Static getKeys

  • getKeys(object: any): string[]
  • Get the list of literals for a given object. Notice that only 1rst depth keys are providen

    Parameters

    • object: any

      A valid object

    Returns string[]

    List of strings with the first level object key names in the same order as defined on the object instance

Static isEqualTo

  • isEqualTo(object1: any, object2: any): boolean
  • Check if two provided objects are identical. Notice that properties order does not alter the comparison. So if two objects have the same properties with exactly the same values, but they appear in a different order on both objects, this method will consider them as equal.

    Parameters

    • object1: any

      First object to compare

    • object2: any

      Second object to compare

    Returns boolean

    true if objects are exactly the same, false if not

Static isObject

  • isObject(value: any): boolean
  • Tells if the given value is an object or not

    Parameters

    • value: any

      A value to check

    Returns boolean

    true if the given value is an object, false otherwise

Static isStringFound

  • isStringFound(object: any, str: string, caseSensitive?: boolean): boolean
  • Check if the provided string is found inside the provided object structure. This method will recursively search inside all the provided object properties and test if the provided string is found. Search will be performed inside any object structures like arrays or other objects. Result will be positive even if any string on the object contains the searched text as a substring.

    Parameters

    • object: any

      The object where the string will be looked for

    • str: string

      The string that will be searched on the object

    • Default value caseSensitive: boolean = true

      True (default) to perform a case sensitive search, false otherwise

    Returns boolean

    True if the string is found anywhere inside the provided object, false otherwise

Static merge

  • merge(destination: any, source: any): any
  • Combine a source object into a destination one by applying a deep merge. All properties from the source will be replaced into the destination object, without altering the destination properties that are not found on source.

    Parameters

    • destination: any

      The object that will be overriden with the source one. The given instance will be permanently modified.

    • source: any

      An object to merge into the destination one. This instance will not be modified

    Returns any

    The destination object instance after being modified by merging the source object into it

Generated using TypeDoc