ltrim.js 424 B

12345678910
  1. var makeString = require('./helper/makeString');
  2. var defaultToWhiteSpace = require('./helper/defaultToWhiteSpace');
  3. var nativeTrimLeft = String.prototype.trimLeft;
  4. module.exports = function ltrim(str, characters) {
  5. str = makeString(str);
  6. if (!characters && nativeTrimLeft) return nativeTrimLeft.call(str);
  7. characters = defaultToWhiteSpace(characters);
  8. return str.replace(new RegExp('^' + characters + '+'), '');
  9. };