• Removes characters from a String, and inserts new characters in their place.

    Works like Array.prototype.splice

    Example

    Truncate to 3 characters

    const truncateTo3 = splice(3);
    const s = truncateTo3("abcde");
    console.log(s); // 'abc'

    Example

    Delete the second character

    const delete2ndChar = splice(1, 1);
    const s = delete2ndChar("abc");
    console.log(s); // 'ac'

    Example

    Replace last character with asterisk ("*")

    const maskLastChar = splice(-1, 1, '*');
    const s = maskLastChar("abc");
    console.log(s); // 'ab*'

    Returns

    the spliced String

    Parameters

    • start: number = 0
    • Optional deleteCount: number
    • replacement: string = ""

    Returns ((str: string, length?: number, normalizedStart?: number) => string)

      • (str: string, length?: number, normalizedStart?: number): string
      • Parameters

        • str: string
        • length: number = str.length
        • normalizedStart: number = ...

        Returns string

Generated using TypeDoc