* Removes leading and trailing whitespace or specified characters from `string`. * * @static * @memberOf _ * @since 3.0.0 * @category String * @param {string} [string=''] The string to trim. * @param {string} [chars=whitespace] The chara
(string, chars, guard)
| 25574 | * // => ['foo', 'bar'] |
| 25575 | */ |
| 25576 | function trim(string, chars, guard) { |
| 25577 | string = toString(string); |
| 25578 | if (string && (guard || chars === undefined)) { |
| 25579 | return string.replace(reTrim, ''); |
| 25580 | } |
| 25581 | if (!string || !(chars = baseToString(chars))) { |
| 25582 | return string; |
| 25583 | } |
| 25584 | var strSymbols = stringToArray(string), |
| 25585 | chrSymbols = stringToArray(chars), |
| 25586 | start = charsStartIndex(strSymbols, chrSymbols), |
| 25587 | end = charsEndIndex(strSymbols, chrSymbols) + 1; |
| 25588 | |
| 25589 | return castSlice(strSymbols, start, end).join(''); |
| 25590 | } |
| 25591 | |
| 25592 | /** |
| 25593 | * Removes trailing whitespace or specified characters from `string`. |
nothing calls this directly
no test coverage detected