Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "string/right-pad/docs/types/index.d"

Index

Functions

Functions

Export assignment rpad

  • rpad(str: string, len: number, pad?: undefined | string): string
  • Right pads a string such that the padded string has a length of at least len.

    Notes

    • An output string is not guaranteed to have a length of exactly len, but to have a length of at least len. To generate a padded string having a length equal to len, post-process a padded string by trimming off excess characters.
    throws

    second argument must be a nonnegative integer

    throws

    padding must have a length greater than 0

    Parameters

    • str: string

      string to pad

    • len: number

      minimum string length

    • Optional pad: undefined | string

      string used to pad (default: ' ')

    Returns string

    padded string

    Example

    var str = rpad( 'a', 5 );
    // returns 'a    '

    Example

    var str = rpad( 'beep', 10, 'p' );
    // returns 'beeppppppp'

    Example

    var str = rpad( 'beep', 12, 'boop' );
    // returns 'beepboopboop'