Skip to content
MapSVG 8/Documentation

default

const default: object;
env: object;
getBrowser: () => object;

Gets browser info (IE, Firefox, Safari).

object

firefox: boolean;
ie: boolean;
safari: boolean;
getDevice: () => object;

Detects if the device is iOS or Android.

object

android: boolean;
ios: boolean;
getMouseCoords: (e) => object;

Gets mouse or touch coordinates from an event.

ParameterTypeDescription
eMouseEvent | TouchEvent | TriggeredEvent<any, any, any, any>

object

x: number;
y: number;
getUserAgent: () => string;

Gets the user agent string in lowercase.

string

isMac: () => boolean;

Checks if the current OS is Mac.

boolean

isPhone: () => boolean;

Checks if the device is a phone (max-width: 767px).

boolean

files: object;
getFileType: (url) => "JS" | "CSS" | "Unknown";

Gets the file type from a URL.

ParameterTypeDescription
urlany

"JS" | "CSS" | "Unknown"

“JS”, “CSS”, or “Unknown”

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

Loads a single JS or CSS file.

ParameterTypeDescription
fileany

Promise<unknown>

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

Loads multiple files (JS or CSS).

ParameterTypeDescription
filesany

Promise<any[]>

funcs: object;
deepMerge: {
<T, U> (target, source): T & U;
<T, U, V> (target, middle, source): T & U & V;
};
<T, U>(target, source): T & U;

Deep merges two or three objects.

Type Parameter
T
U
ParameterTypeDescription
targetT
sourceU

T & U

<T, U, V>(
target,
middle,
source): T & U & V;

Deep merges two or three objects.

Type Parameter
T
U
V
ParameterTypeDescription
targetT
middleU
sourceV

T & U & V

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

boolean

getNestedValue: (obj, path) => any;

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

ParameterTypeDescription
objanyThe object to traverse.
pathstringThe path string (e.g. ‘a.b.c’ or ‘a[b][c]’).

any

The value at the nested path, or undefined if not found.

getNestedValue(obj, 'a.b.c')
getNestedValue(obj, 'a[b][c]')
splitObjectAndField: (fields) => object;
ParameterType
fieldsstring

object

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

Throttles a function call by a delay.

ParameterTypeDescription
methodany
delayany
scopeany
paramsany

void

http: object;
handleFailedRequest: (response) => void;

Handles a failed AJAX request and shows a growl error.

ParameterTypeDescription
responseany

void

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

Compares two version strings (e.g. “1.2.3”).

ParameterTypeDescription
v1any
v2any

-1 | 0 | 1

1 if v1 > v2, -1 if v1 < v2, 0 if equal

isNumber: (n) => boolean;

Checks if a value is a number.

ParameterTypeDescription
nany

boolean

parseBoolean: (string) => boolean;

Parses a string to boolean.

ParameterTypeDescription
stringany

boolean

strings: object;
convertToText: (obj) => any;

Converts an object to a string representation.

ParameterTypeDescription
objany

any

fixColorHash: (color) => string;

Adds a hash to a color string if missing.

ParameterTypeDescription
colorstring

string

functionFromString: (string) => SyntaxError | TypeError;

Converts a string to a function.

ParameterTypeDescription
stringstring

SyntaxError | TypeError

Function or object {error: "error text"}

removeLeadingSlash: (str) => any;

Removes a leading slash from a string.

ParameterTypeDescription
strany

any

safeURL: (url) => any;

Normalizes a URL by removing the protocol and domain.

ParameterTypeDescription
urlany

any

toSnakeCase: (str) => string;

Converts a string to snake_case.

ParameterTypeDescription
strstring

string

ucfirst: (string) => any;

Uppercases the first character of a string.

ParameterTypeDescription
stringany

any