tty-strings
Version:
Tools for working with strings displayed in the terminal
24 lines • 1.17 kB
TypeScript
/**
* Insert, remove or replace characters from a string, similar to the native `Array.splice()` method,
* except that the start index and delete count refer to grapheme clusters within the string.
*
* @remarks
* String may contain ANSI escape codes; inserted content will adopt any ANSI styling applied to the character
* immediately preceding the insert point. ANSI control sequences that are not style or hyperlink sequences
* will be preserved in the output string.
*
* @example
* ```ts
* import { spliceChars } from 'tty-strings';
*
* spliceChars('à̰ b̸ ĉ̥', 2, 1, 'x͎͛ÿz̯̆'); // 'à̰ x͎͛ÿz̯̆ ĉ̥'
* ```
*
* @param string - Input string from which to remove, insert, or replace characters.
* @param start - Character index at which to begin splicing.
* @param deleteCount - Number of characters to remove from the string.
* @param insert - Optional string to be inserted at the index specified by the `start` parameter.
* @returns The modified input string.
*/
export default function spliceChars(string: string, start: number, deleteCount: number, insert?: string): string;
//# sourceMappingURL=spliceChars.d.ts.map