padCenter
Pads both sides of a string to center it within a target length.
padCenter
Signature
typescript
function padCenter(str: string, length: number, char?: string): stringParameters
str- The string to padlength- The target lengthchar- The character to pad with (default: space)
Returns
Centered string.
Examples
typescript
import { padCenter } from 'strio'
padCenter('hello', 11)
// " hello "
padCenter('test', 10, '-')
// "---test---"