source: imaps-frontend/node_modules/lodash-es/endsWith.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.1 KB
Line 
1import baseClamp from './_baseClamp.js';
2import baseToString from './_baseToString.js';
3import toInteger from './toInteger.js';
4import toString from './toString.js';
5
6/**
7 * Checks if `string` ends with the given target string.
8 *
9 * @static
10 * @memberOf _
11 * @since 3.0.0
12 * @category String
13 * @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 * @example
19 *
20 * _.endsWith('abc', 'c');
21 * // => true
22 *
23 * _.endsWith('abc', 'b');
24 * // => false
25 *
26 * _.endsWith('abc', 'b', 2);
27 * // => true
28 */
29function endsWith(string, target, position) {
30 string = toString(string);
31 target = baseToString(target);
32
33 var length = string.length;
34 position = position === undefined
35 ? length
36 : 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
43export default endsWith;
Note: See TracBrowser for help on using the repository browser.