mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-14 12:47:49 +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.
|
* The base implementation of `_.unary` without support for storing wrapper metadata.
|
||||||
*
|
*
|
||||||
@@ -10208,7 +10222,7 @@
|
|||||||
if (typeof value == 'number' || !isString(value)) {
|
if (typeof value == 'number' || !isString(value)) {
|
||||||
return +value;
|
return +value;
|
||||||
}
|
}
|
||||||
value = trim(value);
|
value = baseTrim(value);
|
||||||
var isBinary = reIsBinary.test(value);
|
var isBinary = reIsBinary.test(value);
|
||||||
return (isBinary || reIsOctal.test(value))
|
return (isBinary || reIsOctal.test(value))
|
||||||
? nativeParseInt(value.slice(2), isBinary ? 2 : 8)
|
? nativeParseInt(value.slice(2), isBinary ? 2 : 8)
|
||||||
@@ -12039,7 +12053,7 @@
|
|||||||
} else if (radix) {
|
} else if (radix) {
|
||||||
radix = +radix;
|
radix = +radix;
|
||||||
}
|
}
|
||||||
string = trim(string);
|
string = baseTrim(toString(string));
|
||||||
return nativeParseInt(string, radix || (reHasHexPrefix.test(string) ? 16 : 10));
|
return nativeParseInt(string, radix || (reHasHexPrefix.test(string) ? 16 : 10));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -12432,7 +12446,7 @@
|
|||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
if (guard || chars === undefined) {
|
if (guard || chars === undefined) {
|
||||||
return string.slice(trimmedStartIndex(string), trimmedEndIndex(string) + 1);
|
return baseTrim(string);
|
||||||
}
|
}
|
||||||
chars = (chars + '');
|
chars = (chars + '');
|
||||||
if (!chars) {
|
if (!chars) {
|
||||||
|
|||||||
Reference in New Issue
Block a user