Module: kongUtilObject

Methods

(inner) emulateArray(method, callback, targetopt) → {*}

Emulate functions of Array class.

Parameters:
Name Type Attributes Default Description
method string

name of the corresponding method of Array class.

callback function
target Object <optional>
this

useful to assign this to prototype, though not recommended.

Source:
Returns:

depends on method

Type
*
Example
/// returns [4, 9]
    emulateArray("map", x => x*x, {a: 2, b: 3});

(inner) objectFlat(obj, depthopt, separatoropt, prefixopt) → {Object}

Flatten an object

Parameters:
Name Type Attributes Default Description
obj Object
depth Integer <optional>
Infinity
separator string <optional>
'.'
prefix string <optional>
''
Source:
Returns:
Type
Object
Example
/// returns {x.y: 3, x.q.a: true, x.q.b: null, z: 7}
    objectFlat({x: {y: 3, q: {a: true, b: null}}, z: 7});

(inner) objectMap(callback, targetopt) → {Object.<*>}

Parameters:
Name Type Attributes Default Description
callback function
target Object <optional>
this
Source:
Returns:
Type
Object.<*>

(inner) objectMapAsync(callback, targetopt, skipReturnopt) → {Promise.<(Object|undefined)>}

Parameters:
Name Type Attributes Default Description
callback function
target Object <optional>
this
skipReturn boolean <optional>
false
Source:
Returns:
Type
Promise.<(Object|undefined)>

(inner) objectReduce(callback, initial, targetopt) → {*}

Emulate Array.prototype.reduce.

Parameters:
Name Type Attributes Default Description
callback function
initial *
target Object <optional>
this
Source:
Returns:

depends on callback

Type
*

(inner) objectReduceAsync(callback, initial, targetopt) → {*}

Emulate Array.prototype.reduce in async way.

Parameters:
Name Type Attributes Default Description
callback function
initial *
target Object <optional>
this
Source:
Returns:

depends on callback

Type
*