+var uncurryThis = require('../internals/function-uncurry-this');
var requireObjectCoercible = require('../internals/require-object-coercible');
+var toString = require('../internals/to-string');
var whitespaces = require('../internals/whitespaces');
+var replace = uncurryThis(''.replace);
var whitespace = '[' + whitespaces + ']';
var ltrim = RegExp('^' + whitespace + whitespace + '*');
var rtrim = RegExp(whitespace + whitespace + '*$');
// `String.prototype.{ trim, trimStart, trimEnd, trimLeft, trimRight }` methods implementation
var createMethod = function (TYPE) {
return function ($this) {
- var string = String(requireObjectCoercible($this));
- if (TYPE & 1) string = string.replace(ltrim, '');
- if (TYPE & 2) string = string.replace(rtrim, '');
+ var string = toString(requireObjectCoercible($this));
+ if (TYPE & 1) string = replace(string, ltrim, '');
+ if (TYPE & 2) string = replace(string, rtrim, '');
return string;
};
};