1 var uncurryThis = require('../internals/function-uncurry-this');
2 var requireObjectCoercible = require('../internals/require-object-coercible');
3 var toString = require('../internals/to-string');
4 var whitespaces = require('../internals/whitespaces');
6 var replace = uncurryThis(''.replace);
7 var whitespace = '[' + whitespaces + ']';
8 var ltrim = RegExp('^' + whitespace + whitespace + '*');
9 var rtrim = RegExp(whitespace + whitespace + '*$');
11 // `String.prototype.{ trim, trimStart, trimEnd, trimLeft, trimRight }` methods implementation
12 var createMethod = function (TYPE) {
13 return function ($this) {
14 var string = toString(requireObjectCoercible($this));
15 if (TYPE & 1) string = replace(string, ltrim, '');
16 if (TYPE & 2) string = replace(string, rtrim, '');
22 // `String.prototype.{ trimLeft, trimStart }` methods
23 // https://tc39.es/ecma262/#sec-string.prototype.trimstart
24 start: createMethod(1),
25 // `String.prototype.{ trimRight, trimEnd }` methods
26 // https://tc39.es/ecma262/#sec-string.prototype.trimend
28 // `String.prototype.trim` method
29 // https://tc39.es/ecma262/#sec-string.prototype.trim