/** * @file String transformations: `stripBom`, `stripPaddedSuffix`, * `stripSurroundingQuotes`, `toKebabCase`, `trimCharsFromEnds`, * `trimNewlines`. All are pure functions with no side effects. */ export declare function isTrimmableSpace(code: number): boolean; /** * Strip the Byte Order Mark (BOM) from the beginning of a string. * * The BOM (U+FEFF) is a Unicode character that can appear at the start of a * text file to indicate byte order and encoding. In UTF-16 (JavaScript's * internal string representation), it appears as 0xFEFF. This function removes * it if present, leaving the rest of the string unchanged. * * Most text processing doesn't need to handle the BOM explicitly, but it can * cause issues when parsing JSON, CSV, or other structured data formats that * don't expect a leading invisible character. * * @example * ;```ts * stripBom('\ufeffhello world') // 'hello world' * stripBom('hello world') // 'hello world' * stripBom('') // '' * ``` * * @param str - The string to strip BOM from. * * @returns The string without BOM */ export declare function stripBom(str: string): string; /** * Remove a trailing `suffix` together with any whitespace around it. * * Returns the input unchanged when the suffix is absent, so a caller can * compare identity to learn whether anything was removed. * * The regex form - `/\s*\s*$/` - is polynomial: the leading `\s*` and * the anchored trailing `\s*` make the engine re-scan the whitespace run from * each start position. This walks the end of the string once instead. * * @example * ;```ts * stripPaddedSuffix('# END x env (managed)', '(managed)') // '# END x env' * stripPaddedSuffix('# END x env', '(managed)') // '# END x env' (unchanged) * ``` * * @param str - The string to strip. * @param suffix - The literal suffix to remove. * * @returns The string without the suffix and its padding, or `str` unchanged. */ export declare function stripPaddedSuffix(str: string, suffix: string): string; /** * Strip the surrounding double quotes a PATH entry may carry. * * @example * ;```typescript * stripSurroundingQuotes('"C:\\Program Files"') // 'C:\\Program Files' * ``` */ export declare function stripSurroundingQuotes(entry: string): string; /** * Convert a string to kebab-case (handles camelCase and snake_case). * * Transforms strings from camelCase or snake_case to kebab-case by: * * - Converting uppercase letters to lowercase * - Inserting hyphens before uppercase letters (for camelCase) * - Replacing underscores with hyphens (for snake_case) * * Handles mixed formats (camelCase, snake_case, acronyms) in one pass. Returns * empty string for empty input. * * @example * ;```ts * toKebabCase('helloWorld') // 'hello-world' * toKebabCase('hello_world') // 'hello-world' * toKebabCase('XMLHttpRequest') // 'xmlhttp-request' * toKebabCase('iOS_Version') // 'i-os-version' * toKebabCase('') // '' * ``` * * @param str - The string to convert. * * @returns The kebab-case string */ export declare function toKebabCase(str: string): string; /** * Trim every leading and trailing character that appears in `chars`. * * A single index scan from each end, so cost is linear in the run actually * trimmed. The regex form of this - `/^[-.]+|[-.]+$/g` - is what CodeQL flags * as polynomial-redos: the engine retries the trailing alternative from every * position, so a long string of the trimmed character costs quadratic time. * * @example * ;```ts * trimCharsFromEnds('--a.b--', '-.') // 'a.b' * trimCharsFromEnds('...', '-.') // '' * trimCharsFromEnds('abc', '-.') // 'abc' * ``` * * @param str - The string to trim. * @param chars - Characters to strip from both ends. * * @returns The trimmed string. */ export declare function trimCharsFromEnds(str: string, chars: string): string; /** * Trim newlines from the beginning and end of a string. * * Removes all leading and trailing newline characters (both `\n` and `\r`) from * a string, while preserving any newlines in the middle. This is similar to * `String.prototype.trim()` but specifically targets newlines instead of all * whitespace. * * Optimized for performance by checking the first and last characters before * doing any string manipulation. Returns the original string unchanged if no * newlines are found at the edges. * * @example * ;```ts * trimNewlines('\n\nhello\n\n') // 'hello' * trimNewlines('\r\nworld\r\n') // 'world' * trimNewlines('hello\nworld') // 'hello\nworld' (middle preserved) * trimNewlines(' hello ') // ' hello ' (spaces not trimmed) * trimNewlines('hello') // 'hello' * ``` * * @param str - The string to trim. * * @returns The string with leading and trailing newlines removed */ export declare function trimNewlines(str: string): string;