import { Str } from '@rimbu/typical'; import { CamelCase, FirstOf, KebabCase, LastOf, NoFileExtension, PascalCase, ReplaceAllIf, SnakeCase } from '../typescript'; /** * Converts a string to kebab case * * @param str - The `string` to convert. * * @example * ```ts * kebabCase('the quick brown fox'); // 'the-quick-brown-fox' * kebabCase('the-quick-brown-fox'); // 'the-quick-brown-fox' * kebabCase('the_quick_brown_fox'); // 'the-quick-brown-fox' * kebabCase('theQuickBrownFox'); // 'the-quick-brown-fox' * kebabCase('theQuickBrown Fox'); // 'the-quick-brown-fox' * kebabCase('thequickbrownfox'); // 'thequickbrownfox' * kebabCase('the - quick * brown# fox'); // 'the-quick-brown-fox' * kebabCase('theQUICKBrownFox'); // 'the-quick-brown-fox' * ``` */ export declare function kebabCase(str: T): KebabCase; /** * Converts first character of string literal type to uppercase. * * @param str - The `string` to convert. * * @example * ```ts * capitalize('capitals'); // 'Capitals' * capitalize('Capitals'); // 'Capitals' * capitalize('CapiTALS'); // 'CapiTALS' * capitalize('many Words'); // 'Many Words' * capitalize('!exclaim'); // '!exclaim' * ``` */ export declare function capitalize(str: T): Capitalize; /** * Converts first character of string literal type to lowercase. * * @param str - The `string` to convert. * * @example * ```ts * uncapitalize('capitals'); // 'capitals' * uncapitalize('Capitals'); // 'capitals' * uncapitalize('CapiTALS'); // 'capiTALS' * uncapitalize('many Words'); // 'many Words' * uncapitalize('!exclaim'); // '!exclaim' * ``` */ export declare function uncapitalize(str: T): Uncapitalize; /** * Converts a string to pascal case * * @param str - The `string` to convert. * * @example * ```ts * pascalCase('the quick brown fox'); // 'TheQuickBrownFox' * pascalCase('the_quick_brown_fox'); // 'TheQuickBrownFox' * pascalCase('the-quick-brown-fox'); // 'TheQuickBrownFox' * pascalCase('theQuickBrownFox'); // 'TheQuickBrownFox' * pascalCase('thequickbrownfox'); // 'Thequickbrownfox' * pascalCase('the - quick * brown# fox'); // 'TheQuickBrownFox' * pascalCase('theQUICKBrownFox'); // 'TheQUICKBrownFox' * ``` */ export declare function pascalCase(str: T): PascalCase; /** * Converts a string to snake case * * @param str - The `string` to convert. * * @example * ```ts * snakeCase('the quick brown fox'); // 'the_quick_brown_fox' * snakeCase('the-quick-brown-fox'); // 'the_quick_brown_fox' * snakeCase('the_quick_brown_fox'); // 'the_quick_brown_fox' * snakeCase('theQuickBrownFox'); // 'the_quick_brown_fox' * snakeCase('theQuickBrown Fox'); // 'the_quick_brown_fox' * snakeCase('thequickbrownfox'); // 'thequickbrownfox' * snakeCase('the - quick * brown# fox'); // 'the_quick_brown_fox' * snakeCase('theQUICKBrownFox'); // 'the_q_u_i_c_k_brown_fox' * ``` */ export declare function snakeCase(str: T): SnakeCase; /** * Converts a string to camel case * * @param str - The `string` to convert. * * @example * ```ts * camelCase('the quick brown fox'); // 'theQuickBrownFox' * camelCase('the_quick_brown_fox'); // 'theQuickBrownFox' * camelCase('the-quick-brown-fox'); // 'theQuickBrownFox' * camelCase('theQuickBrownFox'); // 'theQuickBrownFox' * camelCase('thequickbrownfox'); // 'thequickbrownfox' * camelCase('the - quick * brown# fox'); // 'theQuickBrownFox' * camelCase('behold theQuickBrownFox'); // 'beholdTheQuickBrownFox' * camelCase('Behold theQuickBrownFox'); // 'beholdTheQuickBrownFox' * // all caps words are camel-cased * camelCase('The quick brown FOX'), 'theQuickBrownFox'); * // all caps substrings >= 4 chars are camel-cased * camelCase('theQUickBrownFox'); // 'theQUickBrownFox' * camelCase('theQUIckBrownFox'); // 'theQUIckBrownFox' * camelCase('theQUICKBrownFox'); // 'theQuickBrownFox' * ``` */ export declare function camelCase(str: T): CamelCase; /** * Converts a given string to title case. * * @template T - A string type. * @param {T} str - The string to be converted to title case. * @returns {string} - The converted string in title case. * * @example * ```typescript * const result = titleCase("hello world"); * console.log(result); // "Hello World" * ``` */ export declare function titleCase(str: T): string; /** * Converts a given string to sentence case. * The first character of the string will be converted to uppercase, * and the rest of the string will be converted to lowercase. * * @param str - The string to be converted to sentence case. * @returns The converted string in sentence case. */ export declare function toSentenceCase(str: T): string; /** * Converts a PascalCase string to a regular string with spaces. * * @param str - The PascalCase string to be converted. * @returns The converted string with spaces between words. * * @example * ```typescript * fromPascalToRegular("PascalCaseString"); // returns "Pascal Case String" * ``` */ export declare function fromPascalToRegular(str: string): string; /** * Converts a `string` to uppercase. * * @param str - The string to convert to uppercase. * @returns The uppercase version of the input string. * @template T - The type of the input string. */ export declare function upper(str: T): Uppercase; /** * Converts a string to lowercase. * * @param str - The string to convert to lowercase. * @returns The lowercase version of the input string. * @template T - The type of the input string. */ export declare function lower(str: T): Lowercase; /** * Removes all occurrences of a target string from the input string. * * @param str - The input string. * @param target - The target string to be removed. * @returns - The resulting string after removing all occurrences of the target string. * @template T - The type of the input string. * @template R - The type of the target string. */ export declare function removeAll>(str: T, target: R): Str.FilterNot; /** * Replaces all occurrences of a target `string` with a replacement `string` in a given `string`. * * @param str - The input string. * @param target - The target string to be replaced. * @param withExp - The replacement string. * @returns- The resulting string after replacing all occurrences of the target string. * @template T - The type of the input string. * @template R - The type of the target string to be replaced. * @template S - The type of the replacement string. */ export declare function replaceAll, S extends string & Str.NonEmptyString>(str: T, target: R, withExp: S): ReplaceAllIf; /** * Returns the first element of a `string` after splitting it by a separator. * * @param str - The input string. * @param separator - The separator to split the string by. * @returns - The first element of the string after splitting. * @template T - The type of the input string. * @template S - The type of the separator. */ export declare function first(str: T, separator: S): FirstOf; /** * Returns the last part of a `string` after a specified separator. * * @param str - The input string. * @param separator - The separator to split the string. * @returns - The last part of the string after the separator. * @template T - The type of the input string. * @template S - The type of the separator. */ export declare function last(str: T, separator: S): LastOf; /** * Removes the file extension from a given `string`. * * @param str - The string from which to remove the file extension. * @returns The string without the file extension. * @template T - The type of the input string. */ export declare function removeExtension(str: T): NoFileExtension; /** * Reverses a `string`. * * @param str - The string to be reversed. * @returns The reversed string. * @template T - The type of the input string. */ export declare function reverse(str: T): Str.Reverse; /** * Splits a multiline string into an array of strings, where each string has a maximum length of `maxLength`. * * @param text - The multiline string to be split. * @param maxLength - The maximum length of each string in the resulting array. Defaults to 75. * @returns An array of strings, where each string has a maximum length of `maxLength`. */ export declare function chunkMultiline(text: string, maxLength?: number): string[]; /** * Returns the given amount of words from the Lorem ipsum text with a maximum of 200 words. * * @param amount - The number of words to return. * @returns An array of words from the Lorem ipsum text. */ export declare function getLoremIpsumWords(amount: number): string[]; /** * Generates a random string of the specified length. * * @param length The length of the random string to generate. * @returns The randomly generated string. */ export declare function randomString(length: number): string; /** * Generates a random color in hexadecimal format. * * @returns A string representing a random color in the format `#RRGGBB`. */ export declare function randomColor(): `#${string}`; /** * Truncates a string to a specified length and appends ellipsis if necessary. * * @param str - The string to truncate. * @param length - The maximum length of the truncated string. * @returns The truncated string. */ export declare function truncateString(str: string, length: number): string; /** * Truncates a string by replacing the middle portion with ellipsis. * * @param str - The input string to truncate. * @param start - The number of characters to keep from the start of the string. * @param end - The number of characters to keep from the end of the string. * @returns The truncated string with ellipsis in the middle. */ export declare function truncateStringMiddle(str: string, start: number, end: number): string; /** * Finds the shortest word in a given string. * * @param str - The input string. * @returns The shortest word in the string, or undefined if the string is empty. */ export declare function findShortestWord(str: string): string; /** * Finds the longest word in a given string. * * @param str - The input string. * @returns The longest word in the string, or undefined if the string is empty. */ export declare function findLongestWord(str: string): string; /** * Generates a random image URL from Picsum with the specified size. * * @param size - Optional tuple specifying the width and height of the image. Defaults to [400, 300]. * @returns A string representing the URL of the random image. */ export declare function getLoremPicsum(size?: [number, number]): string;