Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "string/truncate/docs/types/index.d"

Index

Functions

Functions

Export assignment truncate

  • truncate(str: string, len: number, ending?: undefined | string): string
  • Truncates a string to a specified length.

    Parameters

    • str: string

      input string

    • len: number

      output string length (including ending)

    • Optional ending: undefined | string

      custom ending (default: ...)

    Returns string

    truncated string

    Example

    var out = truncate( 'beep boop', 7 );
    // returns 'beep...'

    Example

    var out = truncate( 'beep boop', 7, '|' );
    // returns 'beep b|'