mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 10:27:49 +00:00
Make pad methods default to a chars of " " if chars is an empty string.
This commit is contained in:
@@ -4556,12 +4556,13 @@
|
||||
function createPadding(string, length, chars) {
|
||||
length = toInteger(length);
|
||||
|
||||
var strLength = stringSize(string);
|
||||
var strLength = length ? stringSize(string) : 0;
|
||||
if (!length || strLength >= length) {
|
||||
return '';
|
||||
}
|
||||
var padLength = length - strLength;
|
||||
chars = chars === undefined ? ' ' : (chars + '');
|
||||
chars = chars == '' ? ' ' : chars;
|
||||
|
||||
var result = repeat(chars, nativeCeil(padLength / stringSize(chars)));
|
||||
return reHasComplexSymbol.test(chars)
|
||||
@@ -13044,7 +13045,7 @@
|
||||
string = toString(string);
|
||||
length = toInteger(length);
|
||||
|
||||
var strLength = stringSize(string);
|
||||
var strLength = length ? stringSize(string) : 0;
|
||||
if (!length || strLength >= length) {
|
||||
return string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user