basant307/AI_Governance_Project
048
1var baseClamp = require('./_baseClamp'),2 baseToString = require('./_baseToString'),3 toInteger = require('./toInteger'),4 toString = require('./toString');5 6/**7 * Checks if `string` ends with the given target string.8 *9 * @static10 * @memberOf _11 * @since 3.0.012 * @category String13 * @param {string} [string=''] The string to inspect.14 * @param {string} [target] The string to search for.15 * @param {number} [position=string.length] The position to search up to.16 * @returns {boolean} Returns `true` if `string` ends with `target`,17 * else `false`.18 * @example19 *20 * _.endsWith('abc', 'c');21 * // => true22 *23 * _.endsWith('abc', 'b');24 * // => false25 *26 * _.endsWith('abc', 'b', 2);27 * // => true28 */29function endsWith(string, target, position) {30 string = toString(string);31 target = baseToString(target);32 33 var length = string.length;34 position = position === undefined35 ? length36 : baseClamp(toInteger(position), 0, length);37 38 var end = position;39 position -= target.length;40 return position >= 0 && string.slice(position, end) == target;41}42 43module.exports = endsWith;44 