1 | var baseToString = require('./_baseToString'),
|
2 | castSlice = require('./_castSlice'),
|
3 | charsStartIndex = require('./_charsStartIndex'),
|
4 | stringToArray = require('./_stringToArray'),
|
5 | toString = require('./toString');
|
6 |
|
7 |
|
8 | var reTrimStart = /^\s+/;
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 | function 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 |
|
43 | module.exports = trimStart;
|