UNPKG

@newdash/newdash

Version:

javascript/typescript utility library

26 lines (25 loc) 617 B
/** * 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 * @category String * @param string The string to pad. * @param length The padding length. * @param chars The string used as padding. * @returns Returns the padded string. * @example * * ```js * pad('abc', 8) * // => ' abc ' * * pad('abc', 8, '_-') * // => '_-abc_-_' * * pad('abc', 2) * // => 'abc' * ``` */ export declare function pad(string?: string, length?: number, chars?: string): string; export default pad;