Options
All
  • Public
  • Public/Protected
  • All
Menu

Module object

Type aliases

TraversableValue

TraversableValue: undefined | null | boolean | number | string

Traversable value in the object that can be processed.

Functions

clone

  • clone<T>(value: T): T
  • Clone top level properties of the object.

    Type parameters

    • T

    Parameters

    • value: T

      Object to be cloned.

    Returns T

    Shallow copy of the object.

cloneDeep

  • cloneDeep<T>(value: T): T
  • Create a deep copy of the object.

    Type parameters

    • T

    Parameters

    • value: T

      Object to be cloned.

    Returns T

    Deep copy of the object.

flatten

  • flatten(obj: ObjMap): Nullable<ObjMap>
  • Flatten an object, by creating a new one, having all of the nested keys top level.

    Parameters

    • obj: ObjMap

      Object to be flattened.

    Returns Nullable<ObjMap>

    Flattened object.

isEmpty

  • isEmpty<T>(obj: T): boolean
  • Verify if object is empty and contains no keys.

    Type parameters

    • T: ObjMap

      Object type.

    Parameters

    • obj: T

      Object to test for.

    Returns boolean

    Whether object is empty.

isObject

  • isObject<T>(value: T): boolean
  • Verify if value is an object.

    Type parameters

    • T

    Parameters

    • value: T

      Value to test for.

    Returns boolean

    Whether value is an object.

sort

  • sort(obj: ObjMap, sortArray?: boolean): ObjMap
  • Deep-sort an object so its attributes are in lexical order.

    Parameters

    • obj: ObjMap

      Object to sort.

    • sortArray: boolean = true

      Whether to sort the arrays inside of the object.

    Returns ObjMap

    Sorted object.

traverse

  • traverse<T>(objectOrArray: T, processor: TraverseProcessor, alterDeepClone?: boolean): T
  • Iterates over a provided object and processes it's leaves using provided processor. After processing it must return new value or the old one.

    Type parameters

    • T: any[] | ObjMap

      Type of the object or array.

    Parameters

    • objectOrArray: T

      Object which needs to be iterated.

    • processor: TraverseProcessor

      Leaf processor

    • Optional alterDeepClone: boolean

      Alter a deep clone instead of the provided object.

    Returns T

    Traversed object which might be altered by processor.