mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 18:07:49 +00:00
Simplify method juggle in trim modules.
This commit is contained in:
4
trim.js
4
trim.js
@@ -5,8 +5,6 @@ import charsStartIndex from './.internal/charsStartIndex.js'
|
||||
import stringToArray from './.internal/stringToArray.js'
|
||||
import toString from './toString.js'
|
||||
|
||||
const nativeTrim = String.prototype.trim
|
||||
|
||||
/**
|
||||
* Removes leading and trailing whitespace or specified characters from `string`.
|
||||
*
|
||||
@@ -31,7 +29,7 @@ const nativeTrim = String.prototype.trim
|
||||
function trim(string, chars, guard) {
|
||||
string = toString(string)
|
||||
if (string && (guard || chars === undefined)) {
|
||||
return nativeTrim.call(string)
|
||||
return string.trim()
|
||||
}
|
||||
if (!string || !(chars = baseToString(chars))) {
|
||||
return string
|
||||
|
||||
Reference in New Issue
Block a user