* Creates the padding required for `string` based on the given `length`. * The `chars` string is truncated if the number of characters exceeds `length`. * * @private * @param {string} string The string to create padding for. * @param {number} [length=0] The padding length.
(string, length, chars)
| 5079 | * @returns {string} Returns the pad for `string`. |
| 5080 | */ |
| 5081 | function createPadding(string, length, chars) { |
| 5082 | var strLength = string.length; |
| 5083 | length = +length; |
| 5084 | |
| 5085 | if (strLength >= length || !nativeIsFinite(length)) { |
| 5086 | return ''; |
| 5087 | } |
| 5088 | var padLength = length - strLength; |
| 5089 | chars = chars == null ? ' ' : (chars + ''); |
| 5090 | return repeat(chars, ceil(padLength / chars.length)).slice(0, padLength); |
| 5091 | } |
| 5092 | |
| 5093 | /** |
| 5094 | * Creates a function that wraps `func` and invokes it with the optional `this` |
no test coverage detected