Module: common-sk/modules/object

Utility functions for dealing with Objects.
Source:

Methods

(static) applyDelta(delta, o) → {Object}

Returns a copy of object o with values from delta if they exist.
Parameters:
Name Type Description
delta Object A delta object as returned from 'getDelta'.
o Object
Source:
Returns:
Type
Object

(static) equals(a, b) → {boolean}

Returns true if a and b are equal, covers Boolean, Number, String and Arrays and Objects.
Parameters:
Name Type Description
a number | boolean | string | Array | Object
b number | boolean | string | Array | Object
Source:
Returns:
True if the arguments are equal.
Type
boolean

(static) getDelta(o, d) → {Object}

Returns an object with only values that are in o that are different from d. Only works shallowly, i.e. only diffs on the attributes of o and d, and only for the types that equals() supports.
Parameters:
Name Type Description
o Object
d Object
Source:
Returns:
Type
Object
Example
// Returns {a:2}
getDelta({a:2, b:"foo"}, {a:1, b:"foo", c:3.14})

(inner) deepCopy(object) → {Object}

Parameters:
Name Type Description
object Object The object to make a copy of.
Source:
Returns:
Type
Object