pad es-toolkit
Pads a string on both sides to reach a specified length.
Usage
pad(str, length, chars?)
Use pad when you want to pad both sides of a string with characters to match a specified length when the string is shorter than the target length. If the padding cannot be evenly distributed on both sides, the right side will have one more character.
When padding characters cannot be evenly distributed to the target length, the right side will be longer.
Parameters
strstringrequired
The string to pad.
lengthnumberrequired
The target length.
charsstringoptional
The characters to use for padding. Defaults to ' '.
Returns
Returns the padded string.
Source: es-toolkit
Re-exported verbatim from es-toolkit. Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.