applib
Collection of utilities for JSON, objects, events, web request.
- applib
- isJSON(s) ⇒
boolean⏏ - isObject(obj) ⇒
boolean⏏ - parseJSON(inputSerialized) ⇒
object⏏ - stringifyJSON(inputObject) ⇒
string⏏ - compactJSON(inputObject) ⇒
string⏏ - mergeObjects(...objects) ⇒
object⏏ - request(options) ⇒
Promise.<object>⏏
- isJSON(s) ⇒
isJSON(s) ⇒ boolean ⏏
Tests whether the input looks like a JSON string.
Kind: Exported function
Returns: boolean - True if the input is likely a JSON string
| Param | Type | Description |
|---|---|---|
| s | * |
a parameter to be tested |
isObject(obj) ⇒ boolean ⏏
Tests whether the input is an object.
Kind: Exported function
Returns: boolean - True if the input is an object
| Param | Type | Description |
|---|---|---|
| obj | * |
a parameter to be tested |
parseJSON(inputSerialized) ⇒ object ⏏
Converts a JSON string to an object, handling errors so this won't throw an exception.
Kind: Exported function
Returns: object - Null if there is an error, else a valid object
| Param | Type | Description |
|---|---|---|
| inputSerialized | string |
A JSON string |
stringifyJSON(inputObject) ⇒ string ⏏
Converts an object into a JSON string with space/newline formatting, handling errors so it won't throw an exception.
Kind: Exported function
Returns: string - Null if there is an error, else a JSON string
| Param | Type | Description |
|---|---|---|
| inputObject | object |
a valid JavaScript object |
compactJSON(inputObject) ⇒ string ⏏
Same as stringifyJSON except the result is compact without spaces and newlines.
Kind: Exported function
Returns: string - Null if there is an error, else a JSON string
| Param | Type | Description |
|---|---|---|
| inputObject | object |
a valid JavaScript object |
mergeObjects(...objects) ⇒ object ⏏
Performs a deep merge of the input objects.
Kind: Exported function
Returns: object - A JavaScript object
| Param | Type | Description |
|---|---|---|
| ...objects | any |
A parameter set (comma-separated) of objects |
request(options) ⇒ Promise.<object> ⏏
Interface for the npm request HTTP client. The response object from the returned promise contains these important properties: .status, .statusText, .headers, .data
Kind: Exported function
Returns: Promise.<object> - Promise object represents the HTTP response
See
- https://www.npmjs.com/package/axios
- https://nodejs.org/api/https.html#https_https_request_options_callback
- https://nodejs.org/api/http.html#http_class_http_serverresponse
| Param | Type | Description |
|---|---|---|
| options | object |
Parameters that define this request |