Module: util/helpers

Methods

(inner) clone(obj) → {Object}

Returns a deep clone of obj

Parameters:
Name Type Description
obj Object

the object to clone

Source:
Returns:
Type
Object

(inner) defined(obj) → {boolean}

Returns true if obj is a defined value

Parameters:
Name Type Description
obj Object

the value to test

Source:
Returns:
Type
boolean

(inner) isObject(obj) → {boolean}

Returns true if obj is a non-null object
Checking for typeof 'object' without checking for nulls
is a very common source of bugs

Parameters:
Name Type Description
obj Object

the value to test

Source:
Returns:
Type
boolean

(inner) merge(defaults, overrides) → {Object}

Returns a new object combining the two parameters

Parameters:
Name Type Description
defaults Object

The base object

overrides Object

The object to merge from. Where the same property exists in both defaults
and overrides, the values for overrides will be used

Source:
Returns:
Type
Object

(inner) setDeep(obj, path, value) → {undefined}

Sets a value of nested key string descriptor inside a Object.
It changes the passed object.
Ex:
let obj = {a: {b:{c:'initial'}}}
setNestedKey(obj, ['a', 'b', 'c'], 'changed-value')
assert(obj === {a: {b:{c:'changed-value'}}})

Parameters:
Name Type Description
obj Object

Object to set the nested key

path Array

An array to describe the path(Ex: ['a', 'b', 'c'])

value Object

Any value

Source:
Returns:

from https://stackoverflow.com/a/49754647

Type
undefined

(inner) socketName(socket) → {string}

Returns the text used for logging purposes related to this socket

Parameters:
Name Type Description
socket Object

the socket

Source:
Returns:
Type
string