source: imaps-frontend/node_modules/lodash-es/trimStart.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.2 KB
Line 
1import baseToString from './_baseToString.js';
2import castSlice from './_castSlice.js';
3import charsStartIndex from './_charsStartIndex.js';
4import stringToArray from './_stringToArray.js';
5import toString from './toString.js';
6
7/** Used to match leading whitespace. */
8var reTrimStart = /^\s+/;
9
10/**
11 * Removes leading whitespace or specified characters from `string`.
12 *
13 * @static
14 * @memberOf _
15 * @since 4.0.0
16 * @category String
17 * @param {string} [string=''] The string to trim.
18 * @param {string} [chars=whitespace] The characters to trim.
19 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
20 * @returns {string} Returns the trimmed string.
21 * @example
22 *
23 * _.trimStart(' abc ');
24 * // => 'abc '
25 *
26 * _.trimStart('-_-abc-_-', '_-');
27 * // => 'abc-_-'
28 */
29function trimStart(string, chars, guard) {
30 string = toString(string);
31 if (string && (guard || chars === undefined)) {
32 return string.replace(reTrimStart, '');
33 }
34 if (!string || !(chars = baseToString(chars))) {
35 return string;
36 }
37 var strSymbols = stringToArray(string),
38 start = charsStartIndex(strSymbols, stringToArray(chars));
39
40 return castSlice(strSymbols, start).join('');
41}
42
43export default trimStart;
Note: See TracBrowser for help on using the repository browser.