mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-04 00:57:48 +00:00
Bump to v4.7.0.
This commit is contained in:
10
padEnd.js
10
padEnd.js
@@ -1,4 +1,4 @@
|
||||
define(['./_createPadding', './toString'], function(createPadding, toString) {
|
||||
define(['./_createPadding', './_stringSize', './toInteger', './toString'], function(createPadding, stringSize, toInteger, toString) {
|
||||
|
||||
/**
|
||||
* Pads `string` on the right side if it's shorter than `length`. Padding
|
||||
@@ -6,6 +6,7 @@ define(['./_createPadding', './toString'], function(createPadding, toString) {
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 4.0.0
|
||||
* @category String
|
||||
* @param {string} [string=''] The string to pad.
|
||||
* @param {number} [length=0] The padding length.
|
||||
@@ -24,7 +25,12 @@ define(['./_createPadding', './toString'], function(createPadding, toString) {
|
||||
*/
|
||||
function padEnd(string, length, chars) {
|
||||
string = toString(string);
|
||||
return string + createPadding(string, length, chars);
|
||||
length = toInteger(length);
|
||||
|
||||
var strLength = length ? stringSize(string) : 0;
|
||||
return (length && strLength < length)
|
||||
? (string + createPadding(length - strLength, chars))
|
||||
: string;
|
||||
}
|
||||
|
||||
return padEnd;
|
||||
|
||||
Reference in New Issue
Block a user