Class: ObjUtils

ObjUtils

new ObjUtils()

Util methods about object and JSON.
Source:

Methods

(static) equal(src, dest, excludingFields) → {Bool}

Check if src and dest has the same fields and has the same values.
Parameters:
Name Type Description
src Object
dest Object
excludingFields Array These fields will not be compared.
Source:
Returns:
Type
Bool

(static) getLeafFieldCascadeNames(obj, includeFuncFields) → {Array}

Returns an array of cascade names that matches all leaf field of obj. For example, call on object {a: {b: 1, c: 2}, b: 2} will returns ['a.b', 'a.c', 'b'];
Parameters:
Name Type Description
obj Object
includeFuncFields Bool
Source:
Returns:
Type
Array

(static) getOwnedFieldNames(obj, includeFuncFields) → {Array}

Return all name of direct fields of obj. Note that functions will not be included.
Parameters:
Name Type Description
obj Object
includeFuncFields Bool Set to true to include function fields in obj.
Source:
Returns:
Array of field names
Type
Array

(static) getPrototypeOf(obj)

Returns prototype of obj.
Parameters:
Name Type Description
obj Object
Source:

(static) isInstanceOf(obj, classes) → {Bool}

Check if obj is instance of one class of classes array.
Parameters:
Name Type Description
obj Object
classes Array
Source:
Returns:
Type
Bool

(static) isUnset(value) → {Bool}

Check if a value is null or undefined.
Parameters:
Name Type Description
value Variant
Source:
Returns:
Type
Bool

(static) match(src, condition) → {Bool}

Check if fields in condition has the same value with src.
Parameters:
Name Type Description
src Object
condition Object
Source:
Returns:
Type
Bool

(static) notUnset(value) → {Bool}

Check if a value is not null and undefined.
Parameters:
Name Type Description
value Variant
Source:
Returns:
Type
Bool

(static) replacePropName(obj, oldName, newName) → {Object}

Delete obj[oldName] and add a newName prop with the same value. Note that only own property can be replaced.
Parameters:
Name Type Description
obj Object
oldName String
newName String
Source:
Returns:
obj itself.
Type
Object