source: trip-planner-front/node_modules/lodash/startsWith.js@ bdd6491

Last change on this file since bdd6491 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1017 bytes
Line 
1var baseClamp = require('./_baseClamp'),
2 baseToString = require('./_baseToString'),
3 toInteger = require('./toInteger'),
4 toString = require('./toString');
5
6/**
7 * Checks if `string` starts 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=0] The position to search from.
16 * @returns {boolean} Returns `true` if `string` starts with `target`,
17 * else `false`.
18 * @example
19 *
20 * _.startsWith('abc', 'a');
21 * // => true
22 *
23 * _.startsWith('abc', 'b');
24 * // => false
25 *
26 * _.startsWith('abc', 'b', 1);
27 * // => true
28 */
29function startsWith(string, target, position) {
30 string = toString(string);
31 position = position == null
32 ? 0
33 : baseClamp(toInteger(position), 0, string.length);
34
35 target = baseToString(target);
36 return string.slice(position, position + target.length) == target;
37}
38
39module.exports = startsWith;
Note: See TracBrowser for help on using the repository browser.