startsWith.js 350 B

123456789
  1. var makeString = require('./helper/makeString');
  2. var toPositive = require('./helper/toPositive');
  3. module.exports = function startsWith(str, starts, position) {
  4. str = makeString(str);
  5. starts = '' + starts;
  6. position = position == null ? 0 : Math.min(toPositive(position), str.length);
  7. return str.lastIndexOf(starts, position) === position;
  8. };