Code coverage report for master/endsWith.js

Statements: 100% (9 / 9)      Branches: 100% (4 / 4)      Functions: 100% (1 / 1)      Lines: 100% (9 / 9)      Ignored: none     

All files » master/ » endsWith.js
1 2 3 4 5 6 7 8 9 10 11 12 13 141 1   1 33 33 33 19   14   33    
var makeString = require('./helper/makeString');
var toPositive = require('./helper/toPositive');
 
module.exports = function endsWith(str, ends, position) {
  str = makeString(str);
  ends = '' + ends;
  if (typeof position == 'undefined') {
    position = str.length - ends.length;
  } else {
    position = Math.min(toPositive(position), str.length) - ends.length;
  }
  return position >= 0 && str.indexOf(ends, position) === position;
};