mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-05 17:37:50 +00:00
Add baseTrim.
This commit is contained in:
20
lodash.js
20
lodash.js
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user