Options
All
  • Public
  • Public/Protected
  • All
Menu

Module pad

Index

References

Functions String

References

Renames and re-exports __type

String Functions

  • pad(string?: string, length?: number, chars?: string): string
  • Pads string on the left and right sides if it's shorter than length. Padding characters are truncated if they can't be evenly divided by length.

    since

    5.12.0

    example
    pad('abc', 8)
    // => ' abc '

    pad('abc', 8, '_-')
    // => '_-abc_-_'

    pad('abc', 2)
    // => 'abc'

    Parameters

    • string: string = ""

      The string to pad.

    • length: number = 0

      The padding length.

    • chars: string = " "

      The string used as padding.

    Returns string

    Returns the padded string.