Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "string/base/remove-last-grapheme-cluster/docs/types/index.d"

Index

Functions

Functions

removeLast

  • removeLast(str: string, n: number): string
  • Removes the last n grapheme clusters (i.e., user-perceived characters) of a string.

    Parameters

    • str: string

      input string

    • n: number

      number of grapheme clusters to remove

    Returns string

    output string

    Example

    var out = removeLast( 'last man standing', 1 );
    // returns 'last man standin'

    Example

    var out = removeLast( 'presidential election', 1 );
    // returns 'presidential electio'

    Example

    var out = removeLast( 'JavaScript', 1 );
    // returns 'JavaScrip'

    Example

    var out = removeLast( 'Hidden Treasures', 1 );
    // returns 'Hidden Treasure'

    Example

    var out = removeLast( '🐶🐮🐷🐰🐸', 2 );
    // returns '🐶🐮🐷'

    Example

    var out = removeLast( 'foo bar', 5 );
    // returns 'fo'