pad

Pads the input string to the specified width.

pad

Pads the input string to the specified width.

Type: transform

Parameters

  • input (unknown): The input to pad. Non-string inputs are converted to JSON string first.
  • width (number): The target width. Positive values pad to the right, negative values pad to the left.
  • char (string): The character to use for padding. Defaults to space.

Returns

Type: string

The padded string.

Examples

pad("hello", 10) // "hello     "
pad("world", -8, "0") // "000world"
"foo"|pad(5, ".") // "foo.."
Cookie Notice

We use cookies to enhance your browsing experience.