1.2.1 • Published 6 years ago

mostaza-utils v1.2.1

Weekly downloads
16
License
-
Repository
-
Last release
6 years ago

mostaza-utils

Our own utilities

Setup

This library is available on npm, install it with: npm install --save mostaza-utils

API

delay ⇒ Promise.<void>

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.

ParamTypeDescription
numbermsTime to wait for in milliseconds.

formatMacAddress ⇒ String

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.

ParamTypeDescription
plainMacAddressStringThe MAC address without the colon characters.

numberToHex ⇒ String

Transforms a number to its hexadecimal representation.

Kind: global variable Returns: String - The hexadecimal representation of the input number.

ParamTypeDescription
numNumberThe number to convert.

hexToNumber ⇒ Number

Transforms an hexadecimal numeric string to its numeric value.

Kind: global variable Returns: Number - The numeric representation of the input string.

ParamTypeDescription
hexStringThe hexadecimal string to convert.

append ⇒ Array.<any>

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.

ParamTypeDescription
arrayArray.<any>The array.
elany/anyThe value/values to push.

remove ⇒ Array.<any>

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.

ParamTypeDescription
arrayArray.<any>The array.
elanyThe value to pull.

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.

Kind: global variable Returns: Array.<any> - The new array (without the found elements).

ParamTypeDescription
arrayArray.<any>The collection to inspect.
queryObjectThe function invoked per iteration / Object used for the query.

appendOrRemove ⇒ Array.<any>

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.

ParamTypeDescription
arrayArray.<any>The array to inspect and update.
elanyThe value to push/pull.

toInt ⇒ Number

Parses a string to an integer. Useful for converting environment variable (while maintaing the 0 values).

Kind: global variable Returns: Number - The integer output.

ParamTypeDescription
inputNumber | StringThe string to convert to integer.
defaultOutputNumberReturned if the string is not a valid number.

omitUndefined ⇒ Object

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.

ParamTypeDescription
objObjectThe input object.

omitNull ⇒ 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.

ParamTypeDescription
objObjectThe input object.

omitNil ⇒ 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.

ParamTypeDescription
objObjectThe input object.

formatBytes ⇒ String

Formats bytes in a readable string.

Kind: global variable Returns: String - The formatted bytes.

ParamTypeDescription
bytesNumberThe bytes to format.
1.2.1

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.0

7 years ago