@villedemontreal/general-utils
Version:
General utilities library
50 lines • 1.95 kB
TypeScript
/**
* Adds the specified prefix before the provided value.
*
* @param value Value which to add the prefix before.
* @param prefix Prefix to add before the value.
*/
export declare function prefix(value: string, prefix: string): string;
/**
* Adds the specified suffix after the provided value.
*
* @param value Value which to add the suffix after.
* @param suffix Suffix to add after the value.
*/
export declare function suffix(value: string, suffix: string): string;
/**
* Replace all continous sequences of the specified characters
* in a string with the specified replacement.
*
* Examples:
*
* If `str` is "a b", then "deDuplicateChars(str, ' ', '_')"
* would result in: "a_b".
*
* If `str` is "a \r\n \t \n \t b", then "deDuplicateChars(str, ' \t\r\n', ' ')"
* would result in: "a b".
*
* Note that this function will not *trim* all whitespaces at the
* start and end of the string, except if the `replacement` parameter
* is an empty string!
*
* @oaram continuousCharsToReplace A string that act as *a set of characters*
* to find... Their order in the string is not important! Ex: ' \t\n' is
* the same as '\n \t'.
*
* @param trimStartEnd If `true`, the `continuousCharsToReplace` will not
* be replaced on the start and end of the string but *removed*. In otherwords,
* only inside the string those characters will be replaced by the
* `replacement`, they will be removed at the start and end.
*/
export declare function deDuplicateChars(value: string, continuousCharsToReplace: string, replacement: string, trimStartEnd?: boolean): string;
/**
* Replace any sequence of whitespaces, newlines and tabs found
* in a string by a single whitespace. Also trim the start and end
* of the string (no whitespaces).
*
* For more flexibility, use the `deDuplicateChars()` function
* directly!
*/
export declare function trimAll(value: string): string;
//# sourceMappingURL=stringUtils.d.ts.map