12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- var baseClamp = require('./_baseClamp'),
- baseToString = require('./_baseToString'),
- toInteger = require('./toInteger'),
- toString = require('./toString');
- function endsWith(string, target, position) {
- string = toString(string);
- target = baseToString(target);
- var length = string.length;
- position = position === undefined
- ? length
- : baseClamp(toInteger(position), 0, length);
- var end = position;
- position -= target.length;
- return position >= 0 && string.slice(position, end) == target;
- }
- module.exports = endsWith;
|