- ObserverTool
-
A class that provides a means to subscribe to properties of an instance via observer pattern. It acts as a mixin, and should be used as such via the mixin method.
-
arrayUnique(array) ⇒
Array
-
Returns a new array with unique values.
-
arrayEmpty(array) ⇒
boolean
-
Checks if an array is empty.
-
arrayToNumbers(array) ⇒
Array
-
Converts each element in the array to a number.
-
areArraysEqual(array1, array2) ⇒
boolean
-
Checks if two arrays are equal.
-
getColorNode() ⇒
HTMLElement
-
Returns an HTML node used for color validation and other calculations.
-
rgbToHex(rgb) ⇒
string
-
Converts an RGB color value to a hexadecimal color value.
-
stringToHex(color) ⇒
string
-
Converts a color string to a hexadecimal color value.
-
validateColor(value) ⇒
boolean
-
Validates a style color value.
-
encodeValueCommas(text) ⇒
string
-
Encodes commas within double quotes in a text.
-
decodeValueCommas(text) ⇒
string
-
Decodes encoded commas within double quotes in a text.
-
csvToJson(csv, map) ⇒
Array
-
Converts a CSV string to JSON object array.
-
normalizeTimeZeroes(time) ⇒
string
-
Adds zero values if missing from seconds/minutes/hours.
-
getTimeString(date, hasSeconds) ⇒
string
-
Returns a string representation of the current time hh:mm:ss.
-
getTimezoneOffset(date) ⇒
number
-
Returns the timezone offset in hours.
-
isFuture(dateTime) ⇒
boolean
-
Checks if a given date is in the future.
-
isBefore(dateTime, dateTime2) ⇒
boolean
-
Checks if one date is before another date.
-
isAfter(dateTime, dateTime2) ⇒
boolean
-
Checks if one date is after another date.
-
isPast(dateTime) ⇒
boolean
-
Checks if a given date is in the past.
-
isToday(dateTime) ⇒
boolean
-
Checks if a given date is today.
-
isYesterday(dateTime) ⇒
boolean
-
Checks if a given date is yesterday.
-
isTomorrow(dateTime) ⇒
boolean
-
Checks if a given date is tomorrow.
-
isThisWeek(dateTime) ⇒
boolean
-
Checks if a given date is within the current week.
-
isThisMonth(dateTime) ⇒
boolean
-
Checks if a given date is within the current month.
-
isThisYear(dateTime) ⇒
boolean
-
Checks if a given date is within the current year.
-
addTimezoneOffset(date) ⇒
Date
-
Adds the timezone offset to a given date.
-
formatDate(_date, format, addOffset, locale) ⇒
string
-
Formats a given date into a specified format.
-
getTimeAgo(date, referenceDate, format) ⇒
string
-
Returns a formatted string representing the time elapsed since the given date.
-
validateDateFormat(format) ⇒
boolean
-
Validates a date format string.
-
getDaysInMonth(month, year) ⇒
number
-
Returns the number of days in a given month.
-
setDateToMonday(date) ⇒
number
-
Sets a date to the first day of the week.
-
isOperaPhone() ⇒
boolean
-
Checks if the user agent is Opera Mini.
-
isIE11() ⇒
boolean
-
Checks if the user agent is Internet Explorer 11.
-
isIE() ⇒
boolean
-
Checks if the user agent is Internet Explorer (any version).
-
isEdge() ⇒
boolean
-
Checks if the user agent is Edge.
-
isFirefox() ⇒
boolean
-
Checks if the user agent is Firefox.
-
isIOSPhone() ⇒
boolean
-
Checks if the user agent is iOS (iPhone, iPad, iPod).
-
isWebkit() ⇒
boolean
-
Checks if the user agent is WebKit.
-
isChrome() ⇒
boolean
-
Checks if the user agent is Chrome.
-
isSafari() ⇒
boolean
-
Checks if the user agent is Safari.
-
isIOsSafari() ⇒
boolean
-
Checks if the user agent is iOS Safari (iPhone, iPad, iPod or Safari browser).
-
getExtension(file) ⇒
string
-
Get the extension of a file.
-
getFileName(file) ⇒
string
-
Get the name of a file.
-
getMimeType(file) ⇒
string
-
Get the MIME type of a file.
-
getBase64(file) ⇒
Promise.<string>
-
Convert a file to base64 asynchronously.
-
getBase64Sync(file) ⇒
string
-
Convert a file to base64 synchronously.
-
getBase64FromUrl(url) ⇒
Promise.<string>
-
Convert a file from a URL to base64.
-
megaBytesToBytes(megaBytes) ⇒
number
-
Convert megabytes to bytes.
-
formatBytes(bytes, [precision]) ⇒
string
-
Format bytes to a human-readable string.
-
eventContainsFiles(event) ⇒
boolean
-
Check if an event contains files.
-
processFile(file) ⇒
Record.<string, unknown>
-
Given a file object, returns a new object with processed data.
-
getDisplaySize(img) ⇒
Array.<number>
-
Calculates the display size of an image.
- upscale(image, opt)
-
Up-scales an image to the available space in the image HTML container while maintaining the aspect ratio.
-
crop(image, opt) ⇒
CropInterface
-
Crops an image.
-
getMaximumSize([maxSize], [breaks]) ⇒
number
-
Calculates the maximum size based on the screen dimensions.
- attr(node, attributes)
-
Adds attributes to a node.
-
isInView(node) ⇒
boolean
-
Checks if a node is in the viewport.
- addContent(node, content)
-
Adds content to a node.
- setContent(node, content)
-
Sets content to a node.
- style(node, css)
-
Styles a node.
- prepend(node, child)
-
Prepends a child node to a parent node.
-
resolveNode(node) ⇒
HTMLElement
|null
-
Resolves a node.
-
getScrollableParent(node) ⇒
HTMLElement
|null
-
Returns the scrollable parent of a node.
-
getOffset(node) ⇒
Array.<number>
-
Returns the offset of a node.
- onDoubleClick(node, callback, delay)
-
Adds a double click event listener to a node.
-
isObject(obj) ⇒
boolean
-
Checks if an object is an object and not an array or HTMLElement.
-
mergeObjects(obj, obj2, strict) ⇒
Record.<string, unknown>
-
Merges two objects recursively.
-
getPropertyValue(path, object, defaultValue) ⇒
unknown
-
Return the value of a nested object property.
-
countProps(obj) ⇒
number
-
Counts the number of properties in an object.
-
createFormData(obj) ⇒
FormData
-
Creates a FormData object from an object.
- initializeResize(callback)
-
Initializes the resize event listener and sets the flag indicating it has been initialized.
- removeScrollCallback(callback)
-
Removes the specified callback function from the scroll event listener.
- _onResize(event)
-
Executes resize event listener callbacks.
- onResize(callback)
-
Adds a callback function to the resize event listener.
- initializeOnScroll(callback)
-
Initializes the scroll event listener and sets the flag indicating it has been initialized.
- _onScroll(event)
-
Executes scroll event listener callbacks.
- onScroll(callback)
-
Adds a callback function to the scroll event listener.
- removeResizeCallback(callback)
-
Removes the specified callback function from the resize event listener.
-
dashedToCamel(str) ⇒
string
-
Converts a dashed string to camel case.
-
ucFirst(str) ⇒
string
-
Converts the first character of a string to uppercase.
-
lcFirst(str) ⇒
string
-
Converts the first character of a string to lowercase.
-
truncate(str, length) ⇒
string
-
Truncates a string to a specified length.
-
getSafeID(str) ⇒
string
-
Removes unsafe characters from a string to create a safe ID.
-
parseOutlookEmails(str) ⇒
Array.<string>
-
Parses email addresses from a string.
-
mechanize(str) ⇒
string
-
Converts a string to a URL-friendly format.
-
removeWhiteSpace(str) ⇒
string
-
Removes white spaces from a string.
-
extractCurrency(str) ⇒
string
|null
-
Extracts the currency symbol from a string.
-
sanitizeSearchInput(str) ⇒
string
-
Sanitizes a search input by removing special characters and limiting the length.
-
getInitials(str) ⇒
string
-
Retrieves the initials from a string.
-
processTemplate(template, props) ⇒
string
-
Processes a template string and replaces the placeholders with the provided props.
-
getURLParams(url) ⇒
object
-
Extracts query string parameters from a string representing a URL and returns them in an object.
-
arrayToQueryString(propName, array, encode) ⇒
string
-
Transforms an array into a URL query string.
-
decodeURIComponentSafe(value) ⇒
string
-
Decodes a URI component safely.
-
areUrlsEqual(url1, url2) ⇒
boolean
-
Checks if two URLs are equal.
-
removeLastSlash(path) ⇒
string
-
Removes the last slash from a path.
-
sanitizePath(path) ⇒
string
-
Sanitizes the path.
-
removeURLOrigin(url) ⇒
string
|undefined
-
Removes the origin from a URL.
-
sanitizeURL(url) ⇒
string
-
Sanitizes the URL.
-
getURLPath(url) ⇒
string
-
Returns the current path.
-
getURLParam(name, url) ⇒
string
-
Gets a specific query string parameter value from a URL.
-
matchPath(url, route) ⇒
boolean
-
Matches a URL against a route.
-
matchPaths(url, routes) ⇒
boolean
-
Matches a URL against multiple routes.
-
getPathParts(url) ⇒
Array.<string>
-
Returns the parts of the current path.
-
objectToQueryString(object, encode) ⇒
string
-
Transforms an object into a URL query string.
-
editURL(url, params, encode) ⇒
string
-
Edits the query in a URL. This function is designed to work with any kind of string, not necessarily a valid URL format that includes a protocol, such as the one required by the native JS URL constructor, which does not handle relative URLs. Unlike URLSearchParams constructor, this function accepts a full URL and will not encode the path.
-
removeURLParam(name, url) ⇒
string
-
Removes a specific query string parameter from a URL.
-
validateRequired(value) ⇒
boolean
-
Checks if a value is required.
-
validateMaxLength(value, maxLength) ⇒
boolean
|undefined
-
Checks if a value has a maximum length.
-
validateMinLength(value, minLength) ⇒
boolean
|undefined
-
Checks if a value has a minimum length.
-
validateLength(value, length) ⇒
boolean
|undefined
-
Checks if a value has a specific length.
-
validateSize(value, size) ⇒
boolean
-
Checks if a value has a size within a range.
-
validateRegex(value, _regex) ⇒
boolean
-
Checks if a value matches a regular expression.
-
validateNumber(_value) ⇒
boolean
-
Checks if a value is a number.
-
validateColour(value) ⇒
boolean
-
Checks if a value is a valid color.
CropInterface : CropInterface
Kind: global interface
Properties
Name | Type | Description |
---|---|---|
x | number |
The x-coordinate of the crop. |
y | number |
The y-coordinate of the crop. |
width | number |
The width of the crop. |
height | number |
The height of the crop. |
[ratio] | number |
The aspect ratio of the crop. |
[type] | string |
The type of the crop. |
[url] | string |
The URL of the crop. |
[canvas] | HTMLCanvasElement |
The canvas element of the crop. |
A class that provides a means to subscribe to properties of an instance via observer pattern. It acts as a mixin, and should be used as such via the mixin method.
Kind: global class
-
ObserverTool
- instance
- static
Kind: instance property of ObserverTool
Properties
Name | Type | Description |
---|---|---|
subscriptionsInitialized | Record.<string, boolean> |
Key value pair of initialized subscription states. |
Initializes subscriptions for a property, used as a means to prevent accidental duplication of subscriptions.
Kind: instance method of ObserverTool
Param | Type |
---|---|
id | string |
callback | function |
Binds the subscribe, callSubscribers, initializeSubscriptions and unsubscribeProperty methods to the instance.
Kind: static method of ObserverTool
Param | Type |
---|---|
instance | unknown |
Subscribes to a property.
Kind: static method of ObserverTool
Param | Type |
---|---|
property | string |
callback | never |
Unsubscribes from a property.
Kind: static method of ObserverTool
Param | Type |
---|---|
observers | Array.<function()> |
callback | function |
Calls all subscribers of a property.
Kind: static method of ObserverTool
Param | Type |
---|---|
property | string |
value | unknown |
event | unknown |
Returns a new array with unique values.
Kind: global function
Returns: Array
- - The array with unique values.
Param | Type | Description |
---|---|---|
array | Array |
The input array. |
Checks if an array is empty.
Kind: global function
Returns: boolean
- - True if the array is empty, false otherwise.
Param | Type | Description |
---|---|---|
array | Array |
The input array. |
Converts each element in the array to a number.
Kind: global function
Returns: Array
- - The array with each element converted to a number.
Param | Type | Description |
---|---|---|
array | Array |
The input array. |
Checks if two arrays are equal.
Kind: global function
Returns: boolean
- - True if the arrays are equal, false otherwise.
Param | Type | Description |
---|---|---|
array1 | Array |
The first array. |
array2 | Array |
The second array. |
Returns an HTML node used for color validation and other calculations.
Converts an RGB color value to a hexadecimal color value.
Kind: global function
Returns: string
- - The hexadecimal color value.
Param | Type | Description |
---|---|---|
rgb | string |
The RGB color value to convert. |
Converts a color string to a hexadecimal color value.
Kind: global function
Returns: string
- - The hexadecimal color value.
Param | Type | Description |
---|---|---|
color | string |
The color string to convert. |
Validates a style color value.
Kind: global function
Returns: boolean
- - True if the color value is valid, false otherwise.
Param | Type | Description |
---|---|---|
value | string |
The color value to validate. |
Encodes commas within double quotes in a text.
Kind: global function
Returns: string
- - The encoded text.
Param | Type | Description |
---|---|---|
text | string |
The text to encode. |
Decodes encoded commas within double quotes in a text.
Kind: global function
Returns: string
- - The decoded text.
Param | Type | Description |
---|---|---|
text | string |
The text to decode. |
Converts a CSV string to JSON object array.
Kind: global function
Returns: Array
- - The JSON object array.
Param | Type | Description |
---|---|---|
csv | string |
The CSV string to convert. |
map | Record.<string, unknown> |
An optional mapping object to rename the keys in the resulting JSON objects. |
Adds zero values if missing from seconds/minutes/hours.
Kind: global function
Returns: string
- - The normalized time string.
Param | Type | Description |
---|---|---|
time | number |
The time value. |
Returns a string representation of the current time hh:mm:ss.
Kind: global function
Returns: string
- - The formatted time string.
Param | Type | Description |
---|---|---|
date | Date |
The date object. |
hasSeconds | boolean |
Whether to include seconds in the time string. |
Returns the timezone offset in hours.
Kind: global function
Returns: number
- - The timezone offset in hours.
Param | Type | Description |
---|---|---|
date | Date |
The date object. |
Checks if a given date is in the future.
Kind: global function
Returns: boolean
- - True if the date is in the future, false otherwise.
Param | Type | Description |
---|---|---|
dateTime | Date |
The date and time to compare. |
Checks if one date is before another date.
Kind: global function
Returns: boolean
- - True if the first date is before the second date, false otherwise.
Param | Type | Description |
---|---|---|
dateTime | Date |
The first date and time to compare. |
dateTime2 | Date |
The second date and time to compare. |
Checks if one date is after another date.
Kind: global function
Returns: boolean
- - True if the first date is after the second date, false otherwise.
Param | Type | Description |
---|---|---|
dateTime | Date |
The first date and time to compare. |
dateTime2 | Date |
The second date and time to compare. |
Checks if a given date is in the past.
Kind: global function
Returns: boolean
- - True if the date is in the past, false otherwise.
Param | Type | Description |
---|---|---|
dateTime | Date |
The date and time to compare. |
Checks if a given date is today.
Kind: global function
Returns: boolean
- - True if the date is today, false otherwise.
Param | Type | Description |
---|---|---|
dateTime | Date |
The date and time to compare. |
Checks if a given date is yesterday.
Kind: global function
Returns: boolean
- - True if the date is yesterday, false otherwise.
Param | Type | Description |
---|---|---|
dateTime | Date |
The date and time to compare. |
Checks if a given date is tomorrow.
Kind: global function
Returns: boolean
- - True if the date is tomorrow, false otherwise.
Param | Type | Description |
---|---|---|
dateTime | Date |
The date and time to compare. |
Checks if a given date is within the current week.
Kind: global function
Returns: boolean
- - True if the date is within the current week, false otherwise.
Param | Type | Description |
---|---|---|
dateTime | Date |
The date and time to compare. |
Checks if a given date is within the current month.
Kind: global function
Returns: boolean
- - True if the date is within the current month, false otherwise.
Param | Type | Description |
---|---|---|
dateTime | Date |
The date and time to compare. |
Checks if a given date is within the current year.
Kind: global function
Returns: boolean
- - True if the date is within the current year, false otherwise.
Param | Type | Description |
---|---|---|
dateTime | Date |
The date and time to compare. |
Adds the timezone offset to a given date.
Kind: global function
Returns: Date
- - The date object with the timezone offset added.
Param | Type | Description |
---|---|---|
date | Date |
The date object to modify. |
Formats a given date into a specified format.
Kind: global function
Returns: string
- - The formatted date string.
Param | Type | Description |
---|---|---|
_date | Date |
The date object to format. |
format | string |
The format string. |
addOffset | boolean |
Whether to add the timezone offset to the date. |
locale | string |
The locale to use for formatting. |
Returns a formatted string representing the time elapsed since the given date.
Kind: global function
Returns: string
- - The formatted time elapsed string.
Param | Type | Description |
---|---|---|
date | Date |
The date to compare. |
referenceDate | Date |
The reference date to compare against. |
format | string |
The format string. |
Validates a date format string.
Kind: global function
Returns: boolean
- - True if the format is valid, false otherwise.
Param | Type | Description |
---|---|---|
format | string |
The format string to validate. |
Returns the number of days in a given month.
Kind: global function
Returns: number
- - The number of days in the month.
Param | Type |
---|---|
month | number |
year | number |
Sets a date to the first day of the week.
Kind: global function
Returns: number
- - The number of days in the month.
Param | Type | Description |
---|---|---|
date | Date |
The date object. |
Checks if the user agent is Opera Mini.
Kind: global function
Returns: boolean
- True if the user agent is Opera Mini, false otherwise.
Checks if the user agent is Internet Explorer 11.
Kind: global function
Returns: boolean
- True if the user agent is Internet Explorer 11, false otherwise.
Checks if the user agent is Internet Explorer (any version).
Kind: global function
Returns: boolean
- True if the user agent is Internet Explorer, false otherwise.
Checks if the user agent is Edge.
Kind: global function
Returns: boolean
- True if the user agent is Edge, false otherwise.
Checks if the user agent is Firefox.
Kind: global function
Returns: boolean
- True if the user agent is Firefox, false otherwise.
Checks if the user agent is iOS (iPhone, iPad, iPod).
Kind: global function
Returns: boolean
- True if the user agent is iOS, false otherwise.
Checks if the user agent is WebKit.
Kind: global function
Returns: boolean
- True if the user agent is WebKit, false otherwise.
Checks if the user agent is Chrome.
Kind: global function
Returns: boolean
- True if the user agent is Chrome, false otherwise.
Checks if the user agent is Safari.
Kind: global function
Returns: boolean
- True if the user agent is Safari, false otherwise.
Checks if the user agent is iOS Safari (iPhone, iPad, iPod or Safari browser).
Kind: global function
Returns: boolean
- True if the user agent is iOS Safari, false otherwise.
Get the extension of a file.
Kind: global function
Param | Type |
---|---|
file | File |
Get the name of a file.
Kind: global function
Param | Type |
---|---|
file | File |
Get the MIME type of a file.
Kind: global function
Param | Type |
---|---|
file | File |
Convert a file to base64 asynchronously.
Kind: global function
Param | Type |
---|---|
file | File |
Convert a file to base64 synchronously.
Kind: global function
Param | Type |
---|---|
file | File |
Convert a file from a URL to base64.
Kind: global function
Param | Type |
---|---|
url | string |
Convert megabytes to bytes.
Kind: global function
Param | Type |
---|---|
megaBytes | number |
Format bytes to a human-readable string.
Kind: global function
Param | Type |
---|---|
bytes | number |
[precision] | number |
Check if an event contains files.
Kind: global function
Param | Type |
---|---|
event | Event |
Given a file object, returns a new object with processed data.
Kind: global function
Param | Type |
---|---|
file | File |
Calculates the display size of an image.
Kind: global function
Returns: Array.<number>
- - The display size [width, height].
Param | Type | Description |
---|---|---|
img | HTMLImageElement |
The image element. |
Up-scales an image to the available space in the image HTML container while maintaining the aspect ratio.
Kind: global function
Param | Type | Description |
---|---|---|
image | HTMLImageElement |
The image element. |
opt | CropInterface |
The crop options. |
crop(image, opt) ⇒ CropInterface
Crops an image.
Kind: global function
Returns: CropInterface
- - The cropped image data.
Param | Type | Description |
---|---|---|
image | HTMLImageElement |
The image element. |
opt | CropInterface |
The crop options. |
Calculates the maximum size based on the screen dimensions.
Kind: global function
Returns: number
- - The maximum size.
Param | Type | Description |
---|---|---|
[maxSize] | number |
The maximum size of the image. |
[breaks] | Array.<number> |
The breakpoints. |
Adds attributes to a node.
Kind: global function
Param | Type |
---|---|
node | HTMLElement |
attributes | Record.<string, string> |
Checks if a node is in the viewport.
Kind: global function
Param | Type |
---|---|
node | HTMLElement |
Adds content to a node.
Kind: global function
Param | Type |
---|---|
node | HTMLElement |
content | * |
Sets content to a node.
Kind: global function
Param | Type |
---|---|
node | HTMLElement |
content | * |
Styles a node.
Kind: global function
Param | Type |
---|---|
node | HTMLElement |
css | Record.<string, string> |
Prepends a child node to a parent node.
Kind: global function
Param | Type |
---|---|
node | HTMLElement |
child | HTMLElement |
Resolves a node.
Kind: global function
Param | Type |
---|---|
node |
HTMLElement | string
|
Returns the scrollable parent of a node.
Kind: global function
Param | Type |
---|---|
node | HTMLElement |
Returns the offset of a node.
Kind: global function
Param | Type |
---|---|
node | HTMLElement |
Adds a double click event listener to a node.
Kind: global function
Param | Type |
---|---|
node | HTMLElement |
callback | function |
delay | number |
Checks if an object is an object and not an array or HTMLElement.
Kind: global function
Param | Type |
---|---|
obj | unknown |
Merges two objects recursively.
Kind: global function
Param | Type | Description |
---|---|---|
obj | Record.<string, unknown> |
|
obj2 | Record.<string, unknown> |
|
strict | boolean |
Strict mode will filter out properties that are not in the original object. |
Return the value of a nested object property.
Kind: global function
Param | Type |
---|---|
path | string |
object | Record.<string, unknown> |
defaultValue | unknown |
Counts the number of properties in an object.
Kind: global function
Param | Type |
---|---|
obj | Object |
Creates a FormData object from an object.
Kind: global function
Param | Type |
---|---|
obj | Object |
Initializes the resize event listener and sets the flag indicating it has been initialized.
Kind: global function
Param | Type | Description |
---|---|---|
callback | function |
The callback function to be executed on resize. |
Removes the specified callback function from the scroll event listener.
Kind: global function
Param | Type | Description |
---|---|---|
callback | function |
The callback function to be removed. |
Executes resize event listener callbacks.
Kind: global function
Param | Type | Description |
---|---|---|
event | Event |
The resize event handler. |
Adds a callback function to the resize event listener.
Kind: global function
Param | Type | Description |
---|---|---|
callback | function |
The callback function to be added. |
Initializes the scroll event listener and sets the flag indicating it has been initialized.
Kind: global function
Param | Type | Description |
---|---|---|
callback | function |
The callback function to be executed on scroll. |
Executes scroll event listener callbacks.
Kind: global function
Param | Type | Description |
---|---|---|
event | Event |
The resize event. |
Adds a callback function to the scroll event listener.
Kind: global function
Param | Type | Description |
---|---|---|
callback | function |
The callback function to be added. |
Removes the specified callback function from the resize event listener.
Kind: global function
Param | Type | Description |
---|---|---|
callback | function |
The callback function to be removed. |
Converts a dashed string to camel case.
Kind: global function
Returns: string
- The camel case string.
Param | Type | Description |
---|---|---|
str | string |
The dashed string. |
Converts the first character of a string to uppercase.
Kind: global function
Returns: string
- The string with the first character in uppercase.
Param | Type | Description |
---|---|---|
str | string |
The input string. |
Converts the first character of a string to lowercase.
Kind: global function
Returns: string
- The string with the first character in lowercase.
Param | Type | Description |
---|---|---|
str | string |
The input string. |
Truncates a string to a specified length.
Kind: global function
Returns: string
- The truncated string.
Param | Type | Description |
---|---|---|
str | string |
The input string. |
length | number |
The maximum length of the truncated string. |
Removes unsafe characters from a string to create a safe ID.
Kind: global function
Returns: string
- The safe ID string.
Param | Type | Description |
---|---|---|
str | string |
The input string. |
Parses email addresses from a string.
Kind: global function
Returns: Array.<string>
- An array of parsed email addresses.
Param | Type | Description |
---|---|---|
str | string |
The input string. |
Converts a string to a URL-friendly format.
Kind: global function
Returns: string
- The URL-friendly string.
Param | Type | Description |
---|---|---|
str | string |
The input string. |
Removes white spaces from a string.
Kind: global function
Returns: string
- The string without white spaces.
Param | Type | Description |
---|---|---|
str | string |
The input string. |
Extracts the currency symbol from a string.
Kind: global function
Returns: string
| null
- The currency symbol or null if not found.
Param | Type | Description |
---|---|---|
str | string |
The input string. |
Sanitizes a search input by removing special characters and limiting the length.
Kind: global function
Returns: string
- The sanitized search input.
Param | Type | Description |
---|---|---|
str | string |
The input string. |
Retrieves the initials from a string.
Kind: global function
Returns: string
- The initials.
Param | Type | Description |
---|---|---|
str | string |
The input string. |
Processes a template string and replaces the placeholders with the provided props.
Kind: global function
Returns: string
- The processed template.
Param | Type | Description |
---|---|---|
template | string |
The template string. |
props | Record.<string, string> |
The props to replace the placeholders with. |
Extracts query string parameters from a string representing a URL and returns them in an object.
Kind: global function
Returns: object
- - An object representing the query string parameters.
Param | Type | Description |
---|---|---|
url | string |
A URL string. |
Transforms an array into a URL query string.
Kind: global function
Returns: string
- - A URL query string.
Param | Type | Description |
---|---|---|
propName | string |
The name of the property. |
array | Array.<string> |
The array to be converted into a query string. |
encode | boolean |
Whether or not to encode the query string values. |
Decodes a URI component safely.
Kind: global function
Returns: string
- - The decoded value.
Param | Type | Description |
---|---|---|
value | string |
The value to be decoded. |
Checks if two URLs are equal.
Kind: global function
Returns: boolean
- - True if the URLs are equal, false otherwise.
Param | Type | Description |
---|---|---|
url1 | string |
The first URL. |
url2 | string |
The second URL. |
Removes the last slash from a path.
Kind: global function
Returns: string
- - The path without the last slash.
Param | Type | Description |
---|---|---|
path | string |
A path string. |
Sanitizes the path.
Kind: global function
Returns: string
- - The sanitized path.
Param | Type | Description |
---|---|---|
path | string |
A path string. |
Removes the origin from a URL.
Kind: global function
Returns: string
| undefined
- - The URL without the origin.
Param | Type | Description |
---|---|---|
url | string |
A URL string. |
Sanitizes the URL.
Kind: global function
Returns: string
- - The sanitized URL.
Param | Type | Description |
---|---|---|
url | string |
A URL string. |
Returns the current path.
Kind: global function
Returns: string
- - The current path.
Param | Type | Description |
---|---|---|
url | string |
A URL string. |
Gets a specific query string parameter value from a URL.
Kind: global function
Returns: string
- - The value of the query string parameter.
Param | Type | Description |
---|---|---|
name | string |
The name of the query string parameter. |
url | string |
A URL string. |
Matches a URL against a route.
Kind: global function
Returns: boolean
- - True if there is a match, false otherwise.
Param | Type | Description |
---|---|---|
url | string |
Any URL. |
route | Array.<string> |
An array of routes to match against. |
Matches a URL against multiple routes.
Kind: global function
Returns: boolean
- - True if there is a match, false otherwise.
Param | Type | Description |
---|---|---|
url | string |
Any URL. |
routes | Array.<string> |
An array of routes to match against. |
Returns the parts of the current path.
Kind: global function
Returns: Array.<string>
- - The parts of the current path.
Param | Type | Description |
---|---|---|
url | string |
A URL string. |
Transforms an object into a URL query string.
Kind: global function
Returns: string
- - A URL query string.
Param | Type | Description |
---|---|---|
object | object |
An object with properties to be converted into a query string. |
encode | boolean |
Whether or not to encode the query string values. |
Edits the query in a URL. This function is designed to work with any kind of string, not necessarily a valid URL format that includes a protocol, such as the one required by the native JS URL constructor, which does not handle relative URLs. Unlike URLSearchParams constructor, this function accepts a full URL and will not encode the path.
Kind: global function
Returns: string
- - A new URL string with query string parameters based on the params object.
Param | Type | Description |
---|---|---|
url | string |
A URL string. |
params | object |
A set of parameters representing query string values that must be edited in the URL. |
encode | boolean |
Whether or not to encode the query string values. |
Removes a specific query string parameter from a URL.
Kind: global function
Returns: string
- - A new URL string without the specified query string parameter.
Param | Type | Description |
---|---|---|
name | string |
The name of the query string parameter to remove. |
url | string |
A URL string. |
Checks if a value is required.
Kind: global function
Returns: boolean
- - True if the value is required, false otherwise.
Param | Type | Description |
---|---|---|
value | unknown |
The value to be checked. |
Checks if a value has a maximum length.
Kind: global function
Returns: boolean
| undefined
- - True if the value has a maximum length, false otherwise.
Param | Type | Description |
---|---|---|
value | unknown |
The value to be checked. |
maxLength | number |
The maximum length allowed. |
Checks if a value has a minimum length.
Kind: global function
Returns: boolean
| undefined
- - True if the value has a minimum length, false otherwise.
Param | Type | Description |
---|---|---|
value | unknown |
The value to be checked. |
minLength | number |
The minimum length allowed. |
Checks if a value has a specific length.
Kind: global function
Returns: boolean
| undefined
- - True if the value has the specific length, false otherwise.
Param | Type | Description |
---|---|---|
value | unknown |
The value to be checked. |
length | number |
The specific length to be checked against. |
Checks if a value has a size within a range.
Kind: global function
Returns: boolean
- - True if the value has a size within the range, false otherwise.
Param | Type | Description |
---|---|---|
value | unknown |
The value to be checked. |
size | Array.<number> |
The range of sizes allowed. |
Checks if a value matches a regular expression.
Kind: global function
Returns: boolean
- - True if the value matches the regular expression, false otherwise.
Param | Type | Description |
---|---|---|
value | * |
The value to be checked. |
_regex |
string | RegExp
|
The regular expression to be used for matching. |
Checks if a value is a number.
Kind: global function
Returns: boolean
- - True if the value is a number, false otherwise.
Param | Type | Description |
---|---|---|
_value | * |
The value to be checked. |
Checks if a value is a valid color.
Kind: global function
Returns: boolean
- - True if the value is a valid color, false otherwise.
Param | Type | Description |
---|---|---|
value | string |
The value to be checked. |