00001 var baseClamp = require('./_baseClamp'), 00002 baseToString = require('./_baseToString'), 00003 toInteger = require('./toInteger'), 00004 toString = require('./toString'); 00005 00029 function endsWith(string, target, position) { 00030 string = toString(string); 00031 target = baseToString(target); 00032 00033 var length = string.length; 00034 position = position === undefined 00035 ? length 00036 : baseClamp(toInteger(position), 0, length); 00037 00038 var end = position; 00039 position -= target.length; 00040 return position >= 0 && string.slice(position, end) == target; 00041 } 00042 00043 module.exports = endsWith;