/** * Helper functions that have to do with strings. * * @module */ import type { SemanticVersion } from "../interfaces/SemanticVersion.js"; /** Helper function to capitalize the first letter of a string. */ export declare function capitalizeFirstLetter(string: string): string; /** * Helper function to replace all of the ampersands, less than signs, greater than signs, double * quotes, and single quotes in a string with the escaped counterparts. For example, `<` will be * replaced with `<`. */ export declare function escapeHTMLCharacters(string: string): string; /** * Helper function to get the number of consecutive diacritics in a string. * * This is useful for sanitization purposes, since many subsequent diacritics can be a sign of a * malicious string. */ export declare function getNumConsecutiveDiacritics(string: string): number; /** Helper function to check if a string has one or more diacritics in it. */ export declare function hasDiacritic(string: string): boolean; /** * Helper function to check if a string has one or more emoji in it. * * Under the hood, this uses the same regex check as the Zod library. */ export declare function hasEmoji(string: string): boolean; /** From: https://stackoverflow.com/questions/1731190/check-if-a-string-has-white-space */ export declare function hasWhitespace(string: string): boolean; /** Helper function to determine if a string only contains ASCII characters. */ export declare function isASCII(str: string): boolean; /** * From: * https://stackoverflow.com/questions/8334606/check-if-first-letter-of-word-is-a-capital-letter */ export declare function isFirstLetterCapitalized(string: string): boolean; /** * "kebab-case" is the naming style of using all lowercase and hyphens, like "foo-bar". * * An empty string is not considered to be kebab-case. */ export declare function isKebabCase(string: string): boolean; /** Helper function to test if a string contains only lowercase ASCII letters (a through z). */ export declare function isLowerCase(string: string): boolean; /** * Helper function to check if a given string is a valid Semantic Version. * * @see https://semver.org/ */ export declare function isSemanticVersion(versionString: string): boolean; /** Helper function to test if a string contains only uppercase ASCII letters (A through Z). */ export declare function isUpperCase(string: string): boolean; /** Helper function to convert a string from kebab-case to camelCase. */ export declare function kebabCaseToCamelCase(string: string): string; /** Helper function to convert a string from kebab-case to PascalCase. */ export declare function kebabCaseToPascalCase(string: string): string; /** * Helper function to normalize a string. Specifically, this performs the following steps: * * - Removes any non-printable characters, if any. * - Normalizes all newlines to "\n". * - Normalizes all spaces to " ". * - Removes leading/trailing whitespace. * * @see * https://stackoverflow.com/questions/11598786/how-to-replace-non-printable-unicode-characters-javascript */ export declare function normalizeString(string: string): string; /** * Helper function to parse a Semantic Versioning string into its individual constituents. Returns * undefined if the submitted string was not a proper Semantic Version. * * @see https://semver.org/ */ export declare function parseSemanticVersion(versionString: string): SemanticVersion | undefined; /** * Helper function to remove lines from a multi-line string. This function looks for a "-start" and * a "-end" suffix after the marker. Lines with markets will be completely removed from the output. * * For example, by using a marker of "@foo": * * ```txt * line1 * # @foo-start * line2 * line3 * # @foo-end * line4 * ``` * * Would return: * * ```txt * line1 * line4 * ``` */ export declare function removeLinesBetweenMarkers(string: string, marker: string): string; /** Helper function to remove lines from a multi-line string matching a certain other string. */ export declare function removeLinesMatching(string: string, match: string): string; /** * Helper function to remove all non-printable characters from a string. * * @see * https://stackoverflow.com/questions/11598786/how-to-replace-non-printable-unicode-characters-javascript */ export declare function removeNonPrintableCharacters(string: string): string; /** Helper function to remove all whitespace characters from a string. */ export declare function removeWhitespace(string: string): string; /** * Helper function to check if a semantic version is equal to or greater than a second semantic * version. * * @throws If either the version or minimum version are not valid semantic versions. */ export declare function satisfiesSemanticVersion(version: string, minimumVersion: string): boolean; /** Helper function to convert a string from TitleCase (PascalCase) to kebab-case. */ export declare function titleCaseToKebabCase(string: string): string; /** * Helper function to trim a prefix from a string, if it exists. Returns the trimmed string. * * @param string The string to trim. * @param prefix The prefix to trim. * @param trimAll Whether to remove multiple instances of the prefix, if they exist. If this is set * to true, the prefix must only be a single character. */ export declare function trimPrefix(string: string, prefix: string, trimAll?: boolean): string; /** Helper function to trim a suffix from a string, if it exists. Returns the trimmed string. */ export declare function trimSuffix(string: string, prefix: string): string; /** * Helper function to truncate a string to a maximum length. If the length of the string is less * than or equal to the provided maximum length, the string will be returned unmodified. */ export declare function truncateString(string: string, maxLength: number): string; //# sourceMappingURL=string.d.ts.map