You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
14 lines
442 B
14 lines
442 B
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;
|
|
};
|