trimmedLeftIndex.js 501 B

12345678910111213141516171819
  1. var isSpace = require('./isSpace');
  2. /**
  3. * Used by `_.trim` and `_.trimLeft` to get the index of the first non-whitespace
  4. * character of `string`.
  5. *
  6. * @private
  7. * @param {string} string The string to inspect.
  8. * @returns {number} Returns the index of the first non-whitespace character.
  9. */
  10. function trimmedLeftIndex(string) {
  11. var index = -1,
  12. length = string.length;
  13. while (++index < length && isSpace(string.charCodeAt(index))) {}
  14. return index;
  15. }
  16. module.exports = trimmedLeftIndex;