Skip to main content

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
ParameterTypeDescription
eMouseEvent | 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
ParameterTypeDescription
urlany
Returns

"JS" | "CSS" | "Unknown"

"JS", "CSS", or "Unknown"

files.loadFile()

loadFile: (file) => Promise<unknown>;

Loads a single JS or CSS file.

Parameters
ParameterTypeDescription
fileany
Returns

Promise<unknown>

files.loadFiles()

loadFiles: (files) => Promise<any[]>;

Loads multiple files (JS or CSS).

Parameters
ParameterTypeDescription
filesany
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
ParameterTypeDescription
targetT
sourceU
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
ParameterTypeDescription
targetT
middleU
sourceV
Returns

T & U & V

funcs.geocode()

geocode: (query, callback) => boolean;
Parameters
ParameterType
queryany
callbackany
Returns

boolean

funcs.getNestedValue()

getNestedValue: (obj, path) => any;

Gets a nested value from an object using dot or PHP-style bracket notation.

Parameters
ParameterTypeDescription
objanyThe object to traverse.
pathstringThe 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
ParameterType
fieldsstring
Returns

object

field
field: string;
object
object: string;

funcs.throttle()

throttle: (method, delay, scope, params) => void;

Throttles a function call by a delay.

Parameters
ParameterTypeDescription
methodany
delayany
scopeany
paramsany
Returns

void

http

http: object;

http.handleFailedRequest()

handleFailedRequest: (response) => void;

Handles a failed AJAX request and shows a growl error.

Parameters
ParameterTypeDescription
responseany
Returns

void

numbers

numbers: object;

numbers.compareVersions()

compareVersions: (v1, v2) => -1 | 0 | 1;

Compares two version strings (e.g. "1.2.3").

Parameters
ParameterTypeDescription
v1any
v2any
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
ParameterTypeDescription
nany
Returns

boolean

numbers.parseBoolean()

parseBoolean: (string) => boolean;

Parses a string to boolean.

Parameters
ParameterTypeDescription
stringany
Returns

boolean

strings

strings: object;

strings.convertToText()

convertToText: (obj) => any;

Converts an object to a string representation.

Parameters
ParameterTypeDescription
objany
Returns

any

strings.fixColorHash()

fixColorHash: (color) => string;

Adds a hash to a color string if missing.

Parameters
ParameterTypeDescription
colorstring
Returns

string

strings.functionFromString()

functionFromString: (string) => SyntaxError | TypeError;

Converts a string to a function.

Parameters
ParameterTypeDescription
stringstring
Returns

SyntaxError | TypeError

Function or object {error: "error text"}

strings.removeLeadingSlash()

removeLeadingSlash: (str) => any;

Removes a leading slash from a string.

Parameters
ParameterTypeDescription
strany
Returns

any

strings.safeURL()

safeURL: (url) => any;

Normalizes a URL by removing the protocol and domain.

Parameters
ParameterTypeDescription
urlany
Returns

any

strings.toSnakeCase()

toSnakeCase: (str) => string;

Converts a string to snake_case.

Parameters
ParameterTypeDescription
strstring
Returns

string

strings.ucfirst()

ucfirst: (string) => any;

Uppercases the first character of a string.

Parameters
ParameterTypeDescription
stringany
Returns

any