Add baseTrim.

This commit is contained in:
John-David Dalton
2015-11-26 22:51:49 -06:00
parent 70c3d325a0
commit 826af968c8

View File

@@ -874,6 +874,20 @@
});
}
/**
* The base implementation of `_.trim` without support trimming non-whitespace
* characters.
*
* @private
* @param {string} string The string to trim.
* @returns {string} Returns the trimmed string.
*/
function baseTrim(string) {
return string
? string.slice(trimmedStartIndex(string), trimmedEndIndex(string) + 1)
: string;
}
/**
* The base implementation of `_.unary` without support for storing wrapper metadata.
*
@@ -10208,7 +10222,7 @@
if (typeof value == 'number' || !isString(value)) {
return +value;
}
value = trim(value);
value = baseTrim(value);
var isBinary = reIsBinary.test(value);
return (isBinary || reIsOctal.test(value))
? nativeParseInt(value.slice(2), isBinary ? 2 : 8)
@@ -12039,7 +12053,7 @@
} else if (radix) {
radix = +radix;
}
string = trim(string);
string = baseTrim(toString(string));
return nativeParseInt(string, radix || (reHasHexPrefix.test(string) ? 16 : 10));
}
@@ -12432,7 +12446,7 @@
return string;
}
if (guard || chars === undefined) {
return string.slice(trimmedStartIndex(string), trimmedEndIndex(string) + 1);
return baseTrim(string);
}
chars = (chars + '');
if (!chars) {