_baseTrim.js 444 B

1234567891011121314151617181920
  1. var trimmedEndIndex = require('./_trimmedEndIndex');
  2. /** Used to match leading whitespace. */
  3. var reTrimStart = /^\s+/;
  4. /**
  5. * The base implementation of `_.trim`.
  6. *
  7. * @private
  8. * @param {string} string The string to trim.
  9. * @returns {string} Returns the trimmed string.
  10. */
  11. function baseTrim(string) {
  12. return string
  13. ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '')
  14. : string;
  15. }
  16. module.exports = baseTrim;