_charsStartIndex.js 636 B

123456789101112131415161718192021
  1. var baseIndexOf = require('./_baseIndexOf');
  2. /**
  3. * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
  4. * that is not found in the character symbols.
  5. *
  6. * @private
  7. * @param {Array} strSymbols The string symbols to inspect.
  8. * @param {Array} chrSymbols The character symbols to find.
  9. * @returns {number} Returns the index of the first unmatched string symbol.
  10. */
  11. function charsStartIndex(strSymbols, chrSymbols) {
  12. var index = -1,
  13. length = strSymbols.length;
  14. while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
  15. return index;
  16. }
  17. module.exports = charsStartIndex;