ObjectUtil
Provides common object manipulation utilities.
Static Method Summary
Static Public Methods | ||
public static |
depthTraverse(data: object | Array, func: function): * Performs a naive depth traversal of an object / array. |
|
public static |
getAccessorList(data: object): Array Returns a list of accessor keys by traversing the given object. |
|
public static |
safeAccess(data: object, accessor: string, defaultValue: *): * Provides a way to safely access an objects data / entries given an accessor string which describes the entries to walk. |
|
public static |
Compares a source object and values of entries against a target object. |
|
public static |
Provides a way to safely set an objects data / entries given an accessor string which describes the entries to walk. |
Static Public Methods
public static depthTraverse(data: object | Array, func: function): * source
Performs a naive depth traversal of an object / array. The data structure must not have circular references. The result of the callback function is used to modify in place the given data.
Return:
* |
public static getAccessorList(data: object): Array source
Returns a list of accessor keys by traversing the given object.
Params:
Name | Type | Attribute | Description |
data | object | An object to traverse for accessor keys. |
public static safeAccess(data: object, accessor: string, defaultValue: *): * source
Provides a way to safely access an objects data / entries given an accessor string which describes the
entries to walk. To access deeper entries into the object format the accessor string with .
between entries
to walk.
Return:
* |
public static safeEqual(source: object, target: object): boolean source
Compares a source object and values of entries against a target object. If the entries in the source object match
the target object then true
is returned otherwise false
. If either object is undefined or null then false
is returned.
public static safeSet(data: object, accessor: string, value: *, operation: string): boolean source
Provides a way to safely set an objects data / entries given an accessor string which describes the
entries to walk. To access deeper entries into the object format the accessor string with .
between entries
to walk.
Params:
Name | Type | Attribute | Description |
data | object | An object to access entry data. |
|
accessor | string | A string describing the entries to access. |
|
value | * | A new value to set if an entry for accessor is found. |
|
operation | string | (Optional) Operation to perform including: 'add', 'div', 'mult', 'set', 'sub';
default ( |