1.1.6 • Published 6 years ago

@supergeneric/utils v1.1.6

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

supergeneric

supergeneric helper functions

npm version node version support Build Status via Travis CI Coverage Status NPM downloads

Modules

collections/first ⇒ object

returns first value in array

Returns: object - first value/object in an array

ParamTypeDescription
valuesarrayan array of values/objects

collections/last ⇒ object

returns last value in array

Returns: object - last value/object in an array

ParamTypeDescription
valuesarrayan array of values/objects

collections/ascending ⇒ function

ascending sort function. Example: myArray.sort(ascending)

Returns: function - ascending sort function

collections/descending ⇒ function

Descending sort function. Example: myArray.sort(descending)

Returns: function - descending sort function

collections/sortBy ⇒ array

sorts by a predefined key.

Returns: array - sorted by attribute @name

ParamTypeDescription
keystringattribute name for object sorting
descendingbooleanset to true for descending sort

Example

people.sort(sortBy('name'))

collections/onlyNumbers ⇒ array

returns only the numeric values of an array

Returns: array - only numeric values

ParamTypeDescription
valuesarrayan array of values

collections/randomItem ⇒ object

returns a random entry from an array

Returns: object - random value/object from array of values/objects

ParamTypeDescription
itemsarrayan array of values/objects

time/getMilliseconds ⇒ number

converts text durations (e.g. "2 minutes") to milliseconds

Returns: number - milliseconds

ParamTypeDescription
durationstring | numberwill leave numeric values alone but convert string values

Example

getMilliseconds('2 minutes') // 120000
1.1.6

6 years ago

1.1.5

6 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago