logitar-js
Version:
Helper functions distributed by Logitar.
89 lines (88 loc) • 3.99 kB
TypeScript
/**
* Trims the specified string if it is not empty or white-space, or returns undefined.
* @param s The value to clean-trim.
* @returns The trimmed string if it was not empty nor white-space, or undefined otherwise.
*/
export declare function cleanTrim(s?: string): string | undefined;
/**
* Combines the specified segments into an URL.
* @param segments The segments to combine.
* @returns The created URL.
*/
export declare function combineURL(...segments: string[]): string;
/**
* Returns a value indicating whether or not the specified URL is absolute.
* @param url The URL to check.
* @returns True if the URL is absolute, or false otherwise.
*/
export declare function isAbsoluteURL(url: string): boolean;
/**
* Returns a value indicating whether or not the specified character is a digit.
* @param c The character to check.
* @returns True if the character is a digit, or false otherwise.
*/
export declare function isDigit(c: string): boolean;
/**
* Returns a value indicating whether or not the specified character is a letter.
* @param c The character to check.
* @returns True if the character is a letter, or false otherwise.
*/
export declare function isLetter(c: string): boolean;
/**
* Returns a value indicating whether or not the specified character is a letter or a digit.
* @param c The character to check.
* @returns True if the character is a letter or a digit, or false otherwise.
*/
export declare function isLetterOrDigit(c: string): boolean;
/**
* Returns a value indicating whether or not the specified string is undefined or empty.
* @param c The string to check.
* @returns True if the string is undefined or empty, or false otherwise.
*/
export declare function isNullOrEmpty(s?: string): boolean;
/**
* Returns a value indicating whether or not the specified string is undefined, empty or white-space.
* @param c The string to check.
* @returns True if the string is undefined, empty or white-space, or false otherwise.
*/
export declare function isNullOrWhiteSpace(s?: string): boolean;
/**
* Returns a shortened version of the specified string, capped to the specified maximum length.
* @param s The string to shorten.
* @param length The maximum length of the string.
* @returns The original string if its length was below the maximum length, or a string of the specified length, with its last character being a `…`.
*/
export declare function shortify(s: string, length: number): string;
/**
* Formats the specified string into a slug. Slugs are composed of non-empty words separated by hyphens (`-`).
* @param s The string to slugify.
* @returns The formatted slug string.
*/
export declare function slugify(s?: string): string;
/**
* Trims the specified string of the specified characters, removing all occurrences of this character at the start and at the end of the string.
* @param s The string to trim.
* @param c The character to remove from the string's start and end.
* @returns The trimmed string.
*/
export declare function trim(s: string, c: string): string;
/**
* Trims the specified string of the specified characters, removing all occurrences of this character at the end of the string.
* @param s The string to trim.
* @param c The character to remove from the end of the string.
* @returns The trimmed string.
*/
export declare function trimEnd(s: string, c: string): string;
/**
* Trims the specified string of the specified characters, removing all occurrences of this character at the start of the string.
* @param s The string to trim.
* @param c The character to remove from the start of the string.
* @returns The trimmed string.
*/
export declare function trimStart(s: string, c: string): string;
/**
* Replaces accent characters in the specified string by their ASCII character representation. For example, `é` becomes `e`.
* @param s The string to remove the accents.
* @returns The string without accents.
*/
export declare function unaccent(s: string): string;