Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ObjectUtils

Hierarchy

  • ObjectUtils

Index

Constructors

constructor

Methods

Static Private _recursiveAssign

  • _recursiveAssign(target: any, source: any): any

Static copy

  • copy(obj: any): any
  • Function used to copy an object.

    Parameters

    • obj: any

      An any variable

    Returns any

    a copy of the object

Static firstNonEmpty

  • firstNonEmpty(...obj: any[]): any
  • Function used to get first things not empty.

    Parameters

    • Rest ...obj: any[]

      An array of any

    Returns any

    first not empty

Static firstNonNull

  • firstNonNull(...obj: any[]): any
  • Function used to get first things not null.

    Parameters

    • Rest ...obj: any[]

      An array of any

    Returns any

    first not null

Static format

  • format(message: string, data: any): string
  • Function used to format an string. Example: message = It's {value} data = { value: "works" } return It's works

    Parameters

    • message: string

      A string

    • data: any

      An any

    Returns string

    formated message

Static getattr

  • getattr(obj: any, name?: string | string[], defaultValue?: any): any
  • Function used to get an attr inside an object.

    Parameters

    • obj: any

      An any

    • name: string | string[] = null

      An string or an Array

    • defaultValue: any = null

      An any

    Returns any

    if the values is null return the defaultValue, if not return found value

Static isCallable

  • isCallable(obj: any): Boolean
  • Function used to check if something is calleble.

    Parameters

    • obj: any

      An any variable

    Returns Boolean

    true or false depends of the obj

Static isEmpty

  • isEmpty(obj: any): boolean
  • Function used to check if something is empty.

    Parameters

    • obj: any

      An any variable

    Returns boolean

    boolean

Static isString

  • isString(obj: any): boolean
  • Function used to check if a variable is string.

    Parameters

    • obj: any

      An any variable

    Returns boolean

    boolean

Static Protected prepareName

  • prepareName(name: string | string[]): string[]

Static recursiveAssign

  • recursiveAssign(...obj: any[]): any
  • Function used to assign recursively objects at target.

    Parameters

    • Rest ...obj: any[]

      An Array

    Returns any

    target object with values of the sources objects

Static round

  • round(num: number, len?: number): number
  • Function used to rounds a number

    example
    Example usage of round without len. ```typescript // returns 3.59 ObjectUtils.round(3.5892222); ```
    example
    Example usage of round with len. ```typescript // returns 3.589 ObjectUtils.round(3.5892222,3); ```

    Parameters

    • num: number

      A number

    • Optional len: number

      Number of characters after the comma

    Returns number

    Formated number

Static setattr

  • setattr(obj: any, name: string | string[], value: any): boolean
  • Function used to set an attr inside an object.

    Parameters

    • obj: any

      An any

    • name: string | string[]

      An string or an Array

    • value: any

      An any

    Returns boolean

    false if obj is null or undefined

Static strToBoolOrStr

  • strToBoolOrStr(str: any): string | Boolean
  • Function used to check if an string is bool or is just a string.

    Parameters

    • str: any

    Returns string | Boolean

    Boolean or string

Static zipToObject

  • zipToObject(keys: string[], values: any[]): any
  • Function used to mount an object with two arrays.

    Parameters

    • keys: string[]

      Array of string.

    • values: any[]

      Array of any.

    Returns any

    An object

Generated using TypeDoc