Skip to content

Padding

Adds padding to given string.

padStart

Pads the start of a string with a specified fill string a certain number of times.

// Basic Usage
padStart('hello', '+', 3) // +++hello
// Limiting total length
padStart('hello', '-', 4, 8) // ---hello

padStart

Pads the end of a string with a specified fill string a certain number of times.

// Basic Usage
padStart('hello', '+', 3) // +++hello
// Limiting total length
padStart('hello', '-', 4, 8) // ---hello

padBidirectional

Pads a string with a specified fill string a certain number of times on both ends.

// Basic usage
padBidirectional('hello', '*', 2) // '**hello**'
// Limiting total length
padBidirectional('world', '-', 3, 10) // '--world---'
// Controlling padding distribution
padBidirectional('example', '_', 2, 10, 0) // '**example_'