This library is available on npm, install it with: npm install --save mostaza-utils
- delay ⇒
Promise.<void>
Simple syntactic sugar over setTimeout that looks good when using the async/await pattern.
- formatMacAddress ⇒
String
Formats a numeric string MAC address by adding the the right colon charactes.
- numberToHex ⇒
String
Transforms a number to its hexadecimal representation.
- hexToNumber ⇒
Number
Transforms an hexadecimal numeric string to its numeric value.
- append ⇒
Array.<any>
Returns a new array containing the contents of the array list, followed by the given element/s.
- remove ⇒
Array.<any>
Removes an element from the array (returns a new array). Doesn't work with collections (array of objects).
- removeBy ⇒
Array.<any>
Iterates over elements of the array/collection, deleting the first element predicate returns truthy for and returning a new array. See Lodash.find() for more info on the quey param.
- appendOrRemove ⇒
Array.<any>
Removes an element from an array if it exists in it, otherwise pushes it (aka toggles it). Returns a new array.
- toInt ⇒
Number
Parses a string to an integer. Useful for converting environment variable (while maintaing the 0 values).
- omitUndefined ⇒
Object
Creates a new object composed of all the properties of the input object that do not have an undefined value.
- omitNull ⇒
Object
Creates a new object composed of all the properties of the input object that do not have an null value.
- omitNil ⇒
Object
Creates a new object composed of all the properties of the input object that do not have an undefined or null value.
- formatBytes ⇒
String
Formats bytes in a readable string.
Simple syntactic sugar over setTimeout that looks good when using the async/await pattern.
Kind: global variable
Returns: Promise.<void>
- A promise that resolves when the given time has ended.
Param | Type | Description |
---|---|---|
number | ms |
Time to wait for in milliseconds. |
Formats a numeric string MAC address by adding the the right colon charactes.
Kind: global variable
Returns: String
- The MAC address with the colon characters.
Param | Type | Description |
---|---|---|
plainMacAddress | String |
The MAC address without the colon characters. |
Transforms a number to its hexadecimal representation.
Kind: global variable
Returns: String
- The hexadecimal representation of the input number.
Param | Type | Description |
---|---|---|
num | Number |
The number to convert. |
Transforms an hexadecimal numeric string to its numeric value.
Kind: global variable
Returns: Number
- The numeric representation of the input string.
Param | Type | Description |
---|---|---|
hex | String |
The hexadecimal string to convert. |
Returns a new array containing the contents of the array list, followed by the given element/s.
Kind: global variable
Returns: Array.<any>
- The new array.
Param | Type | Description |
---|---|---|
array | Array.<any> |
The array. |
el | any/any |
The value/values to push. |
Removes an element from the array (returns a new array). Doesn't work with collections (array of objects).
Kind: global variable
Returns: Array.<any>
- The new array.
Param | Type | Description |
---|---|---|
array | Array.<any> |
The array. |
el | any |
The value to pull. |
Iterates over elements of the array/collection, deleting the first element predicate returns truthy for and returning a new array. See Lodash.find() for more info on the quey param.
Kind: global variable
Returns: Array.<any>
- The new array (without the found elements).
Param | Type | Description |
---|---|---|
array | Array.<any> |
The collection to inspect. |
query | Object |
The function invoked per iteration / Object used for the query. |
Removes an element from an array if it exists in it, otherwise pushes it (aka toggles it). Returns a new array.
Kind: global variable
Returns: Array.<any>
- The new array.
Param | Type | Description |
---|---|---|
array | Array.<any> |
The array to inspect and update. |
el | any |
The value to push/pull. |
Parses a string to an integer. Useful for converting environment variable (while maintaing the 0 values).
Kind: global variable
Returns: Number
- The integer output.
Param | Type | Description |
---|---|---|
input | Number | String |
The string to convert to integer. |
defaultOutput | Number |
Returned if the string is not a valid number. |
Creates a new object composed of all the properties of the input object that do not have an undefined value.
Kind: global variable
Returns: Object
- A new object without properties with undefined values.
Param | Type | Description |
---|---|---|
obj | Object |
The input object. |
Creates a new object composed of all the properties of the input object that do not have an null value.
Kind: global variable
Returns: Object
- A new object without properties with null values.
Param | Type | Description |
---|---|---|
obj | Object |
The input object. |
Creates a new object composed of all the properties of the input object that do not have an undefined or null value.
Kind: global variable
Returns: Object
- A new object without properties with undefined and null values.
Param | Type | Description |
---|---|---|
obj | Object |
The input object. |
Formats bytes in a readable string.
Kind: global variable
Returns: String
- The formatted bytes.
Param | Type | Description |
---|---|---|
bytes | Number |
The bytes to format. |