Options
All
  • Public
  • Public/Protected
  • All
Menu

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

Index

Functions

Functions

Export assignment lpad

  • lpad(str: string, len: number, pad?: undefined | string): string
  • Left 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 = lpad( 'a', 5 );
    // returns '    a'

    Example

    var str = lpad( 'beep', 10, 'b' );
    // returns 'bbbbbbbeep'

    Example

    var str = lpad( 'boop', 12, 'beep' );
    // returns 'beepbeepboop'