Methods
ajax(endpoint, cb, options) → {function}
a clean Ajax handler, setting options for fetch(). Optionally log errors utilizing the responder &
Debug features.
Parameters:
| Name | Type | Description |
|---|---|---|
endpoint |
String | String URL to hit with the ajax request. |
cb |
function | optional callback function |
options |
Object | override fetch options |
- Source:
Returns:
cb optional callback function
- Type
- function
filterHTMLTags(string) → {String}
Filters HTML tags and special chars that turn into HTML tags (like how < = <)
Parameters:
| Name | Type | Description |
|---|---|---|
string |
String | String data containing tags or psuedo-tags to be striped. |
- Source:
Returns:
Cleaned text string, stripping all HTML tags and psuedo-tags.
- Type
- String
getPropertySafely(obj, propPath) → {String|Array|Object|function|undefined}
Safe way to get a nested property. It can be used to safely retrieve
a nested property from an object without having to do all the checks (e.g. if an
object is undefined and you're trying to get `obj.property.nested.property` it will
throw an error).
Parameters:
| Name | Type | Description |
|---|---|---|
obj |
Object | Object to retrieve nested property from |
propPath |
String | Path to the property to be retrieved |
- Source:
Returns:
Returns the value of the property or undefined
- Type
- String | Array | Object | function | undefined
getStringSafely(thing) → {string|null}
A safer version of toString(). To avoid getting 'NaN' or other
non-real string values. It will coerce strings out of booleans,
numbers, objects with their own toString() function, and of course
strings.
Parameters:
| Name | Type | Description |
|---|---|---|
thing |
Boolean | String | Object | thing to be converted to string. |
- Source:
Returns:
the coerced string, null if unable.
- Type
- string | null
isEmptyObject(obj) → {Boolean}
Checks if an object is empty.
Parameters:
| Name | Type | Description |
|---|---|---|
obj |
Object | The object to check for properties. |
- Source:
Returns:
True if the object doesn't have any own properties. Otherwise it returns false.
- Type
- Boolean
isEmptyString(string) → {Boolean}
Checks to see if a string provided is empty or not.
Parameters:
| Name | Type | Description |
|---|---|---|
string |
String | string to be tested |
- Source:
Returns:
will return true if thing is null, undefined, NaN.
Otherwise it will return false.
- Type
- Boolean
isNull(thing) → {Boolean}
Checks to see if the provided item is null or not
Parameters:
| Name | Type | Description |
|---|---|---|
thing |
Object | item to be tested |
- Source:
Returns:
will return true if thing is a valid object. Otherwise it will return false.
- Type
- Boolean
isNullish(thing) → {Boolean}
More specific than falsy. '', 0, and -0 will evaluate
as false so that functions that want to validly return
these can do so, and be tested for problematic response.
Parameters:
| Name | Type | Description |
|---|---|---|
thing |
Object | thing to be tested |
- Source:
Returns:
will return true if thing is null, undefined, NaN.
Otherwise it will return false.
- Type
- Boolean
isNumber(thing) → {Boolean}
Checks to see if the provided item is a valid number or not
Parameters:
| Name | Type | Description |
|---|---|---|
thing |
Array | String | Object | item to be tested for its value as a number |
- Source:
Returns:
will return true if thing is a valid number. Otherwise it will return false.
- Type
- Boolean
isObject(ele) → {Boolean}
takes a JS type and checks if it is '[object Object]'
Parameters:
| Name | Type | Description |
|---|---|---|
ele |
String | Array | Object | Number | any Javascript type |
- Source:
Returns:
true if ele '[object Object]' else it returns false
- Type
- Boolean
isStringy(thing) → {Boolean}
Using the same rules as getStringSafely returns true if a string can be safely coerced, false if not.
Parameters:
| Name | Type | Description |
|---|---|---|
thing |
String | Object | thing to be tested. |
- Source:
Returns:
true if it can be safely coerced into a string. false if not.
- Type
- Boolean
isType(expr, object) → {Boolean}
Checks to see if the provided item is a valid type match
Parameters:
| Name | Type | Description |
|---|---|---|
expr |
String | a String version of the 'type' you're looking to check for a match |
object |
String | Array | function | Object | the item you're checking against |
- Source:
Returns:
will return true if thing is a valid match. Otherwise it will return false.
- Type
- Boolean
isUndefined(thing) → {Boolean}
Checks to see if the provided item is undefined or not
Parameters:
| Name | Type | Description |
|---|---|---|
thing |
Array | String | Object | item to be tested for its existence |
- Source:
Returns:
will return true if thing is null, undefined, NaN. Otherwise it will return null.
- Type
- Boolean
isValidObject(ele) → {Boolean}
checks if an element is an object and it is not empty
Parameters:
| Name | Type | Description |
|---|---|---|
ele |
String | Array | Object | Number | any Javascript type |
- Source:
Returns:
true if ele '[object Object]' and not {} else it returns
false
- Type
- Boolean
promise(signature, response, reject) → {Promise}
an Ajax error response handler. Internal to Json only.
Parameters:
| Name | Type | Description |
|---|---|---|
signature |
Object | Error message setup info |
response |
function | AJax data that fetch got |
reject |
Boolean | otherwise resolve |
- Source:
Returns:
A Promise resolution or rejection with the data, status
- Type
- Promise
responder(arguments) → {function}
a clean Ajax response handler, optionally logged utilizing the Debug feature.
Parameters:
| Name | Type | Description |
|---|---|---|
arguments |
Object | Ajax response information to be logged. Only `message` is required, others are optional. |
- Source:
Returns:
cb optional callback function
- Type
- function
testDefaults()
Runs a set of default tests to check if the instance and all of its defined items
exist and are the correct type.
- Source: