1 | var requireObjectCoercible = require('../internals/require-object-coercible');
|
2 | var whitespaces = require('../internals/whitespaces');
|
3 |
|
4 | var whitespace = '[' + whitespaces + ']';
|
5 | var ltrim = RegExp('^' + whitespace + whitespace + '*');
|
6 | var rtrim = RegExp(whitespace + whitespace + '*$');
|
7 |
|
8 |
|
9 | var createMethod = function (TYPE) {
|
10 | return function ($this) {
|
11 | var string = String(requireObjectCoercible($this));
|
12 | if (TYPE & 1) string = string.replace(ltrim, '');
|
13 | if (TYPE & 2) string = string.replace(rtrim, '');
|
14 | return string;
|
15 | };
|
16 | };
|
17 |
|
18 | module.exports = {
|
19 |
|
20 |
|
21 | start: createMethod(1),
|
22 |
|
23 |
|
24 | end: createMethod(2),
|
25 |
|
26 |
|
27 | trim: createMethod(3)
|
28 | };
|