diff options
Diffstat (limited to 'deps/npm/node_modules/cli-table2/node_modules/lodash/string/endsWith.js')
-rw-r--r-- | deps/npm/node_modules/cli-table2/node_modules/lodash/string/endsWith.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/deps/npm/node_modules/cli-table2/node_modules/lodash/string/endsWith.js b/deps/npm/node_modules/cli-table2/node_modules/lodash/string/endsWith.js new file mode 100644 index 0000000000..26821e2661 --- /dev/null +++ b/deps/npm/node_modules/cli-table2/node_modules/lodash/string/endsWith.js @@ -0,0 +1,40 @@ +var baseToString = require('../internal/baseToString'); + +/* Native method references for those with the same name as other `lodash` methods. */ +var nativeMin = Math.min; + +/** + * 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 = baseToString(string); + target = (target + ''); + + var length = string.length; + position = position === undefined + ? length + : nativeMin(position < 0 ? 0 : (+position || 0), length); + + position -= target.length; + return position >= 0 && string.indexOf(target, position) == position; +} + +module.exports = endsWith; |