supergeneric
supergeneric helper functions
Modules
-
collections/first ⇒
object
-
returns first value in array
-
collections/last ⇒
object
-
returns last value in array
-
collections/ascending ⇒
function
-
ascending sort function. Example: myArray.sort(ascending)
-
collections/descending ⇒
function
-
Descending sort function. Example: myArray.sort(descending)
-
collections/sortBy ⇒
array
-
sorts by a predefined key.
-
collections/onlyNumbers ⇒
array
-
returns only the numeric values of an array
-
collections/randomItem ⇒
object
-
returns a random entry from an array
-
time/getMilliseconds ⇒
number
-
converts text durations (e.g. "2 minutes") to milliseconds
object
collections/first ⇒ returns first value in array
Returns: object
- first value/object in an array
Param | Type | Description |
---|---|---|
values | array |
an array of values/objects |
object
collections/last ⇒ returns last value in array
Returns: object
- last value/object in an array
Param | Type | Description |
---|---|---|
values | array |
an array of values/objects |
function
collections/ascending ⇒ ascending sort function. Example: myArray.sort(ascending)
Returns: function
- ascending sort function
function
collections/descending ⇒ Descending sort function. Example: myArray.sort(descending)
Returns: function
- descending sort function
array
collections/sortBy ⇒ sorts by a predefined key.
Returns: array
- sorted by attribute @name
Param | Type | Description |
---|---|---|
key | string |
attribute name for object sorting |
descending | boolean |
set to true for descending sort |
Example
people.sort(sortBy('name'))
array
collections/onlyNumbers ⇒ returns only the numeric values of an array
Returns: array
- only numeric values
Param | Type | Description |
---|---|---|
values | array |
an array of values |
object
collections/randomItem ⇒ returns a random entry from an array
Returns: object
- random value/object from array of values/objects
Param | Type | Description |
---|---|---|
items | array |
an array of values/objects |
number
time/getMilliseconds ⇒ converts text durations (e.g. "2 minutes") to milliseconds
Returns: number
- milliseconds
Param | Type | Description |
---|---|---|
duration |
string | number
|
will leave numeric values alone but convert string values |
Example
getMilliseconds('2 minutes') // 120000