Variable: default
const default: object;
Type declaration
env
env: object;
env.getBrowser()
getBrowser: () => object;
Gets browser info (IE, Firefox, Safari).
Returns
object
firefox
firefox: boolean;
ie
ie: boolean;
safari
safari: boolean;
env.getDevice()
getDevice: () => object;
Detects if the device is iOS or Android.
Returns
object
android
android: boolean;
ios
ios: boolean;
env.getMouseCoords()
getMouseCoords: (e) => object;
Gets mouse or touch coordinates from an event.
Parameters
Parameter | Type | Description |
---|---|---|
e | MouseEvent | TouchEvent | TriggeredEvent <any , any , any , any > |
Returns
object
x
x: number;
y
y: number;
env.getUserAgent()
getUserAgent: () => string;
Gets the user agent string in lowercase.
Returns
string
env.isMac()
isMac: () => boolean;
Checks if the current OS is Mac.
Returns
boolean
env.isPhone()
isPhone: () => boolean;
Checks if the device is a phone (max-width: 767px).
Returns
boolean
files
files: object;
files.getFileType()
getFileType: (url) => "JS" | "CSS" | "Unknown";
Gets the file type from a URL.
Parameters
Parameter | Type | Description |
---|---|---|
url | any |
Returns
"JS"
| "CSS"
| "Unknown"
"JS", "CSS", or "Unknown"
files.loadFile()
loadFile: (file) => Promise<unknown>;
Loads a single JS or CSS file.
Parameters
Parameter | Type | Description |
---|---|---|
file | any |
Returns
Promise
<unknown
>
files.loadFiles()
loadFiles: (files) => Promise<any[]>;
Loads multiple files (JS or CSS).
Parameters
Parameter | Type | Description |
---|---|---|
files | any |
Returns
Promise
<any
[]>
funcs
funcs: object;
funcs.deepMerge()
deepMerge: {
<T, U> (target, source): T & U;
<T, U, V> (target, middle, source): T & U & V;
};
Call Signature
<T, U>(target, source): T & U;
Deep merges two or three objects.
Type Parameters
Type Parameter |
---|
T |
U |
Parameters
Parameter | Type | Description |
---|---|---|
target | T | |
source | U |
Returns
T
& U
Call Signature
<T, U, V>(
target,
middle,
source): T & U & V;
Deep merges two or three objects.
Type Parameters
Type Parameter |
---|
T |
U |
V |
Parameters
Parameter | Type | Description |
---|---|---|
target | T | |
middle | U | |
source | V |
Returns
T
& U
& V
funcs.geocode()
geocode: (query, callback) => boolean;
Parameters
Parameter | Type |
---|---|
query | any |
callback | any |
Returns
boolean
funcs.getNestedValue()
getNestedValue: (obj, path) => any;
Gets a nested value from an object using dot or PHP-style bracket notation.
Parameters
Parameter | Type | Description |
---|---|---|
obj | any | The object to traverse. |
path | string | The path string (e.g. 'a.b.c' or 'a[b][c]'). |
Returns
any
The value at the nested path, or undefined if not found.
Example
getNestedValue(obj, 'a.b.c')
getNestedValue(obj, 'a[b][c]')
funcs.splitObjectAndField()
splitObjectAndField: (fields) => object;
Parameters
Parameter | Type |
---|---|
fields | string |
Returns
object
field
field: string;
object
object: string;
funcs.throttle()
throttle: (method, delay, scope, params) => void;
Throttles a function call by a delay.
Parameters
Parameter | Type | Description |
---|---|---|
method | any | |
delay | any | |
scope | any | |
params | any |
Returns
void
http
http: object;
http.handleFailedRequest()
handleFailedRequest: (response) => void;
Handles a failed AJAX request and shows a growl error.
Parameters
Parameter | Type | Description |
---|---|---|
response | any |
Returns
void
numbers
numbers: object;
numbers.compareVersions()
compareVersions: (v1, v2) => -1 | 0 | 1;
Compares two version strings (e.g. "1.2.3").
Parameters
Parameter | Type | Description |
---|---|---|
v1 | any | |
v2 | any |
Returns
-1
| 0
| 1
1 if v1 > v2, -1 if v1 < v2, 0 if equal
numbers.isNumber()
isNumber: (n) => boolean;
Checks if a value is a number.
Parameters
Parameter | Type | Description |
---|---|---|
n | any |
Returns
boolean
numbers.parseBoolean()
parseBoolean: (string) => boolean;
Parses a string to boolean.
Parameters
Parameter | Type | Description |
---|---|---|
string | any |
Returns
boolean
strings
strings: object;
strings.convertToText()
convertToText: (obj) => any;
Converts an object to a string representation.
Parameters
Parameter | Type | Description |
---|---|---|
obj | any |
Returns
any
strings.fixColorHash()
fixColorHash: (color) => string;
Adds a hash to a color string if missing.
Parameters
Parameter | Type | Description |
---|---|---|
color | string |
Returns
string
strings.functionFromString()
functionFromString: (string) => SyntaxError | TypeError;
Converts a string to a function.
Parameters
Parameter | Type | Description |
---|---|---|
string | string |
Returns
SyntaxError
| TypeError
Function or object {error: "error text"}
strings.removeLeadingSlash()
removeLeadingSlash: (str) => any;
Removes a leading slash from a string.
Parameters
Parameter | Type | Description |
---|---|---|
str | any |
Returns
any
strings.safeURL()
safeURL: (url) => any;
Normalizes a URL by removing the protocol and domain.
Parameters
Parameter | Type | Description |
---|---|---|
url | any |
Returns
any
strings.toSnakeCase()
toSnakeCase: (str) => string;
Converts a string to snake_case.
Parameters
Parameter | Type | Description |
---|---|---|
str | string |
Returns
string
strings.ucfirst()
ucfirst: (string) => any;
Uppercases the first character of a string.
Parameters
Parameter | Type | Description |
---|---|---|
string | any |
Returns
any