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.
18 lines
524 B
18 lines
524 B
5 months ago
|
var toValueString = require('./toValueString')
|
||
|
|
||
|
/**
|
||
|
* 判断字符串是否在源字符串的尾部
|
||
|
*
|
||
|
* @param {String} str 字符串
|
||
|
* @param {String/Number} val 值
|
||
|
* @param {Number} startIndex 开始索引
|
||
|
* @return {String}
|
||
|
*/
|
||
|
function endsWith (str, val, startIndex) {
|
||
|
var rest = toValueString(str)
|
||
|
var argsLen = arguments.length
|
||
|
return argsLen > 1 && (argsLen > 2 ? rest.substring(0, startIndex).indexOf(val) === startIndex - 1 : rest.indexOf(val) === rest.length - 1)
|
||
|
}
|
||
|
|
||
|
module.exports = endsWith
|