Namespace: object

qui.utils.object

Methods

(static) assignDefault(dest, src) → {Object}

Assign values to an object, in place, but only if corresponding keys are missing.

Parameters:
Name Type Description
dest Object
src Object
Source:
Returns:

the given dest object

Type
Object

(static) combine(…objs) → {Object}

Combine two or more objects into a single object by merging their keys and values.

Parameters:
Name Type Attributes Description
objs Object <repeatable>

objects to combine

Source:
Returns:

the combined object

Type
Object

(static) copy(orig, deepopt) → {Object}

Clone an object by copying its entries into a new object. Optionally recurse into inner objects and arrays.

Parameters:
Name Type Attributes Description
orig Object

original object to copy

deep Boolean <optional>

set to true to perform a deep copy (defaults to false)

Source:
Returns:
Type
Object

(static) deepEquals(obj1, obj2) → {Boolean}

A deep equals() operator that will recursively compare any non-primitive objects to validate the equality.

Parameters:
Name Type Description
obj1 Object

the first object of the comparison

obj2 Object

the second object of the comparison

Source:
Returns:

true if the two objects are deeply equal, falseotherwise

Type
Boolean

(static) filter(obj, func, thisArgopt) → {Object}

Filter object entries. This function is similar to Array's filter method, but applied on objects.

Parameters:
Name Type Attributes Description
obj Object
func function

a function called with each key and value as arguments; only entries for which this function returns a true value will be kept

thisArg * <optional>

optional this argument to be used when calling func

Source:
Returns:

the filtered object

Type
Object

(static) findKey(obj, func, thisArgopt) → {String}

Search an object for an entry that matches a condition and return the corresponding key.

Parameters:
Name Type Attributes Description
obj Object
func function

function that implements the search condition; it is called with value and key as arguments

thisArg * <optional>

optional this argument to be used when calling func

Source:
Returns:

the matched key, or undefined if no entry matched

Type
String

(static) findValue(obj, func, thisArgopt) → {String}

Search an object for an entry that matches a condition and return the corresponding value.

Parameters:
Name Type Attributes Description
obj Object
func function

function that implements the search condition; it is called with key and value as arguments

thisArg * <optional>

optional this argument to be used when calling func

Source:
Returns:

the matched value, or undefined if no entry matched

Type
String

(static) forEach(obj, func, thisArgopt, sortKeyFuncopt)

Parse an object, calling a function for each entry.

Parameters:
Name Type Attributes Description
obj Object
func function

function to be called for each entry; it is called with the entry (array of key and value) as argument

thisArg * <optional>

optional this argument to be used when calling func

sortKeyFunc function <optional>

optional function used to extract key from each entry when sorting entries; no sorting is performed unless this function is supplied

Source:

(static) fromEntries(entries) → {Object}

Create an object from a list of entries. Each entry is an array of two elements: the key and its associated value.

Parameters:
Name Type Description
entries Array.<Array>
Source:
Returns:
Type
Object

(static) map(obj, func, thisArgopt) → {Object}

Map object entries. This function is similar to Array's map method, but applied on objects.

Parameters:
Name Type Attributes Description
obj Object
func function

a function called with each key and value as arguments; it is expected to return an array with two elements, the mapped key and value

thisArg * <optional>

optional this argument to be used when calling func

Source:
Returns:

the mapped object

Type
Object

(static) mapKey(obj, func, thisArgopt) → {Object}

Map object keys.

Parameters:
Name Type Attributes Description
obj Object
func function

a function called with each key and value as arguments; it is expected to return the mapped key

thisArg * <optional>

optional this argument to be used when calling func

Source:
Returns:

the mapped object

Type
Object

(static) mapValue(obj, func, thisArgopt) → {Object}

Map object values.

Parameters:
Name Type Attributes Description
obj Object
func function

a function called with each value and key as arguments; it is expected to return the mapped value

thisArg * <optional>

optional this argument to be used when calling func

Source:
Returns:

the mapped object

Type
Object

(static) pop(obj, key, defopt) → {*}

Remove a key from an object, returning it.

Parameters:
Name Type Attributes Description
obj Object
key String
def * <optional>

an optional default value to return if key is missing

Source:
Returns:
Type
*

(static) setDefault(obj, key, value) → {*}

Insert a value into an object, but only if it's not already present, and return it.

Parameters:
Name Type Description
obj Object
key String
value *
Source:
Returns:
Type
*