Members
(inner, constant) emptyArr :Array
- Description:
Reusable, empty frozen array. Renamed for legibility
- Source:
Reusable, empty frozen array. Renamed for legibility
Type:
- Array
(inner, constant) emptyObj :Object
- Description:
Reuseable empty, frozen object
- Source:
Reuseable empty, frozen object
Type:
- Object
(inner, constant) noOpArr :Array
- Description:
Reusable, empty frozen array. Renamed for consistency
- Source:
Reusable, empty frozen array. Renamed for consistency
Type:
- Array
(inner, constant) noOpObj :Object
- Description:
Reuseable empty, frozen object
- Source:
Reuseable empty, frozen object
Type:
- Object
(inner, constant) noPropArr :Array
- Description:
Reusable, empty frozen array
- Source:
Reusable, empty frozen array
Type:
- Array
(inner, constant) noPropObj :Object
- Description:
Reusable frozen object that contains a
content
object. Useful
- Source:
Reusable frozen object that contains a content
object. Useful
Type:
- Object
Methods
(inner) either(val1opt, val2opt, checkopt) → {*}
- Description:
Determines the correct value to return, by calling the passed in check function.
If no check function, then it uses the softFalsy method.
- Source:
Examples
either(0, 2)
// Returns 0
either(null, 2)
// Returns 2
either(1, 2, (val1, val2) => { return true })
// Returns 1
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
val1 |
* |
<optional> |
return if passes in check method return true |
val2 |
* |
<optional> |
return if passed in check method returns false |
check |
function |
<optional> |
called to determine which value to return |
Returns:
- Type
- *
(inner) exists(value) → {Boolean}
- Description:
Checks if a value exists. NOT undefined || null
- Source:
Examples
exists(0)
// Returns true
exists(null)
// Returns false
exists('')
// Returns true
exists(NaN)
// Returns false
Parameters:
Name | Type | Description |
---|---|---|
value |
* | Item to check if exists |
Returns:
- If the item exists or not
- Type
- Boolean
(inner) isEmpty(val) → {Boolean}
- Description:
Checks if the value is empty.
- Source:
Examples
isEmpty('')
// Returns true
isEmpty({})
// Returns true
isEmpty([ 1 ])
// Returns false
Parameters:
Name | Type | Description |
---|---|---|
val |
* | value to check |
Returns:
if the value is empty
- Type
- Boolean
(inner) isSame(val1, val2) → {Boolean}
- Description:
Checks if the passed in values are exactly the same.
- Source:
Example
isSame(1, 1)
// Returns true
Parameters:
Name | Type | Description |
---|---|---|
val1 |
* | value to compare |
val2 |
* | value to compare |
Returns:
is the values are the same
- Type
- Boolean
(inner) isValidDate(date) → {Boolean}
- Description:
Checks is passed in date is a valid date.
- Source:
Examples
isValidDate(new Date())
// Returns true
isValidDate(new Date().toString())
// Returns true
isValidDate('12345678')
// Returns false
Parameters:
Name | Type | Description |
---|---|---|
date |
Date | String | value to check |
Returns:
T/F - if passed in date is a valid date
- Type
- Boolean
(inner) strToType(val) → {any|string}
- Description:
Converts a string to its own type if possible.
- Source:
Examples
strToType('12345678')
// Returns 12345678
strToType('{}')
// Returns {}
strToType('[]')
// Returns []
Parameters:
Name | Type | Description |
---|---|---|
val |
* | value to convert |
Returns:
converted value || string if can't convert
- Type
- any | string
(inner) tri(cb, argsopt)
- Description:
Wraps the passed in callback in a try catch, then calls the callback Returns the callbacks response or undefined if the callback throws
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
cb |
function | Function to wrap in a try catch, then call |
||
args |
Array.<any> |
<optional> |
any[]
|
Arguments to pass to the passed in callback |
Returns:
(inner) typeOf(val) → {String}
- Description:
Gets the type of the passed in val.
- Source:
Examples
typeOf(1)
// Returns Number
typeOf('')
// Returns String
Parameters:
Name | Type | Description |
---|---|---|
val |
* | value to get type for |
Returns:
type of the value
- Type
- String