1 var createPadding = require('./_createPadding'),
2 stringSize = require('./_stringSize'),
3 toInteger = require('./toInteger'),
4 toString = require('./toString');
7 * Pads `string` on the right side if it's shorter than `length`. Padding
8 * characters are truncated if they exceed `length`.
14 * @param {string} [string=''] The string to pad.
15 * @param {number} [length=0] The padding length.
16 * @param {string} [chars=' '] The string used as padding.
17 * @returns {string} Returns the padded string.
23 * _.padEnd('abc', 6, '_-');
29 function padEnd(string, length, chars) {
30 string = toString(string);
31 length = toInteger(length);
33 var strLength = length ? stringSize(string) : 0;
34 return (length && strLength < length)
35 ? (string + createPadding(length - strLength, chars))
39 module.exports = padEnd;