1 | import baseToString from './_baseToString.js';
|
2 | import castSlice from './_castSlice.js';
|
3 | import charsEndIndex from './_charsEndIndex.js';
|
4 | import stringToArray from './_stringToArray.js';
|
5 | import toString from './toString.js';
|
6 | import trimmedEndIndex from './_trimmedEndIndex.js';
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 | function trimEnd(string, chars, guard) {
|
28 | string = toString(string);
|
29 | if (string && (guard || chars === undefined)) {
|
30 | return string.slice(0, trimmedEndIndex(string) + 1);
|
31 | }
|
32 | if (!string || !(chars = baseToString(chars))) {
|
33 | return string;
|
34 | }
|
35 | var strSymbols = stringToArray(string),
|
36 | end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
|
37 |
|
38 | return castSlice(strSymbols, 0, end).join('');
|
39 | }
|
40 |
|
41 | export default trimEnd;
|