mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 15:57:48 +00:00
20 lines
502 B
JavaScript
20 lines
502 B
JavaScript
define(['./isSpace'], function(isSpace) {
|
|
|
|
/**
|
|
* Used by `_.trim` and `_.trimRight` to get the index of the last non-whitespace
|
|
* character of `string`.
|
|
*
|
|
* @private
|
|
* @param {string} string The string to inspect.
|
|
* @returns {number} Returns the index of the last non-whitespace character.
|
|
*/
|
|
function trimmedRightIndex(string) {
|
|
var index = string.length;
|
|
|
|
while (index-- && isSpace(string.charCodeAt(index))) {}
|
|
return index;
|
|
}
|
|
|
|
return trimmedRightIndex;
|
|
});
|