text-no-case
Version:
Convert text to all lowercase letters with spaces between words
46 lines (45 loc) • 1.51 kB
TypeScript
/**
* Configuration options for text transformation functions.
*
* @public
*/
export interface Options {
/** Regular expression(s) to split words on boundaries */
splitRegexp?: RegExp | RegExp[];
/** Regular expression(s) to strip unwanted characters */
stripRegexp?: RegExp | RegExp[];
/** Delimiter to use between words in the output */
delimiter?: string;
/** Custom transformation function for each word */
transform?: (part: string, index: number, parts: string[]) => string;
}
/**
* Normalize text into a consistent format that other transformation functions can use.
*
* This is the foundation function used by all other case conversion libraries.
* It handles word splitting, character stripping, and applies transformations
* to create a normalized output.
*
* @param input - The string to normalize
* @param options - Configuration options for the normalization
* @returns The normalized string
*
* @example
* ```typescript
* noCase("helloWorld") // "hello world"
* noCase("user_profile_data") // "user profile data"
* noCase("XMLHttpRequest") // "xml http request"
* noCase("iPhone") // "i phone"
*
* // With custom delimiter
* noCase("hello world", { delimiter: "-" }) // "hello-world"
*
* // With custom transform
* noCase("hello world", {
* transform: (word) => word.toUpperCase()
* }) // "HELLO WORLD"
* ```
*
* @public
*/
export declare function noCase(input: string, options?: Options): string;