Module: Utils

Methods

(static) arrayToKvp(array) → {Object}

Helper function to convert an array, to key/value pairs. ie. ['foo', 'bar', 'meow', 'rawr'] => {foo: 'bar', meow: 'rawr'}
Parameters:
Name Type Description
array Array.<(string|number)> The array to convert
Source:
Returns:
The object that was converted
Type
Object

(static) delay(ms) → {Promise.<void>}

Helper function to resolve promise after ms.
Parameters:
Name Type Description
ms number Number of milliseconds to delay
Source:
Returns:
A promise that resovles after ms milliseconds
Type
Promise.<void>

(static) lazy(getter, updater) → {Promise.<void>}

Helper function to provide promises from getters/setters. Used to lazily initialize values when the getter returns undefined.
Parameters:
Name Type Description
getter function A function to return the value
updater function A function that sets a value, that can be subsequently retrieved from the getter function
Source:
Returns:
A promise that resovles after ms milliseconds
Type
Promise.<void>

(static) parseAgoString(text) → {number}

Helper function to parse time strings (Mainly on the profile pages) into seconds.
For example: 2m ago => 120
Parameters:
Name Type Description
text string The string of text to parse. ie 5s ago
Source:
Throws:
If the string doesn't match the format suffix (s/m/h/d/y).
Type
ChatExchangeError
Returns:
The number
Type
number