/** * Truncates a string to a maximum length, adding a suffix if needed that defaults to `...`. */ export declare const truncate: (str: string, maxLength: number, suffix?: string) => string; /** * Removes characters inclusive of `stripped`. */ export declare const strip_start: (source: string, stripped: string) => string; /** * Removes characters inclusive of `stripped`. */ export declare const strip_end: (source: string, stripped: string) => string; /** * Removes characters inclusive of `stripped`. */ export declare const strip_after: (source: string, stripped: string) => string; /** * Removes characters inclusive of `stripped`. */ export declare const strip_before: (source: string, stripped: string) => string; /** * Adds the substring `ensured` to the start of the `source` string if it's not already present. */ export declare const ensure_start: (source: string, ensured: string) => string; /** * Adds the substring `ensured` to the end of the `source` string if it's not already present. */ export declare const ensure_end: (source: string, ensured: string) => string; /** * Removes leading and trailing spaces from each line of a string. */ export declare const deindent: (str: string) => string; /** * Returns a plural suffix based on a count. */ export declare const plural: (count: number | undefined | null, suffix?: string) => string; /** * Returns the count of graphemes in a string, the individually rendered characters. */ export declare const count_graphemes: (str: string) => number; /** * Strips ANSI escape sequences from a string. */ export declare const strip_ansi: (str: string) => string; /** * Stringifies a value like `JSON.stringify` but with some corner cases handled better. * * @source https://2ality.com/2025/04/stringification-javascript.html */ export declare const stringify: (value: unknown) => string; /** * Calculate the display width of a string in terminal columns. * - Strips ANSI escape codes (they have 0 width) * - Emojis and other wide characters take 2 columns * - Tab characters take 4 columns * - Newlines and other control characters take 0 columns * - Uses `Intl.Segmenter` to properly handle grapheme clusters (e.g., family emoji "๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ") */ export declare const string_display_width: (str: string) => number; /** * Pad a string to a target display width (accounting for wide characters). */ export declare const pad_width: (str: string, target_width: number, align?: "left" | "right") => string; /** * Calculates the Levenshtein distance between two strings. * Useful for typo detection and fuzzy matching. * * @returns the edit distance between the strings */ export declare const levenshtein_distance: (a: string, b: string) => number; /** * Escapes a string for use inside a single-quoted JS string literal. * * Uses a single-pass regex replacement to escape backslashes, single quotes, * newlines, carriage returns, and Unicode line/paragraph separators. */ export declare const escape_js_string: (value: string) => string; /** * Check if content appears to be binary. * * Checks for null bytes in the first 8KB of content. */ export declare const string_is_binary: (content: string) => boolean; //# sourceMappingURL=string.d.ts.map