X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=node_modules%2Fgrunt-legacy-log-utils%2Fnode_modules%2Flodash%2FendsWith.js;fp=node_modules%2Fgrunt-legacy-log-utils%2Fnode_modules%2Flodash%2FendsWith.js;h=5da6b5e3072a571bbb69d2de58b9839f787779fd;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/node_modules/grunt-legacy-log-utils/node_modules/lodash/endsWith.js b/node_modules/grunt-legacy-log-utils/node_modules/lodash/endsWith.js new file mode 100644 index 000000000..5da6b5e30 --- /dev/null +++ b/node_modules/grunt-legacy-log-utils/node_modules/lodash/endsWith.js @@ -0,0 +1,39 @@ +var baseClamp = require('./_baseClamp'), + toInteger = require('./toInteger'), + toString = require('./toString'); + +/** + * Checks if `string` ends with the given target string. + * + * @static + * @memberOf _ + * @category String + * @param {string} [string=''] The string to search. + * @param {string} [target] The string to search for. + * @param {number} [position=string.length] The position to search from. + * @returns {boolean} Returns `true` if `string` ends with `target`, else `false`. + * @example + * + * _.endsWith('abc', 'c'); + * // => true + * + * _.endsWith('abc', 'b'); + * // => false + * + * _.endsWith('abc', 'b', 2); + * // => true + */ +function endsWith(string, target, position) { + string = toString(string); + target = typeof target == 'string' ? target : (target + ''); + + var length = string.length; + position = position === undefined + ? length + : baseClamp(toInteger(position), 0, length); + + position -= target.length; + return position >= 0 && string.indexOf(target, position) == position; +} + +module.exports = endsWith;