trim.js 414 B

123456789101112131415
  1. var toString = require('../lang/toString');
  2. var WHITE_SPACES = require('./WHITE_SPACES');
  3. var ltrim = require('./ltrim');
  4. var rtrim = require('./rtrim');
  5. /**
  6. * Remove white-spaces from beginning and end of string.
  7. */
  8. function trim(str, chars) {
  9. str = toString(str);
  10. chars = chars || WHITE_SPACES;
  11. return ltrim(rtrim(str, chars), chars);
  12. }
  13. module.exports = trim;