1 | 'use strict';
|
2 | var uncurryThis = require('../internals/function-uncurry-this');
|
3 | var requireObjectCoercible = require('../internals/require-object-coercible');
|
4 | var toString = require('../internals/to-string');
|
5 | var whitespaces = require('../internals/whitespaces');
|
6 |
|
7 | var replace = uncurryThis(''.replace);
|
8 | var ltrim = RegExp('^[' + whitespaces + ']+');
|
9 | var rtrim = RegExp('(^|[^' + whitespaces + '])[' + whitespaces + ']+$');
|
10 |
|
11 |
|
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, '$1');
|
17 | return string;
|
18 | };
|
19 | };
|
20 |
|
21 | module.exports = {
|
22 |
|
23 |
|
24 | start: createMethod(1),
|
25 |
|
26 |
|
27 | end: createMethod(2),
|
28 |
|
29 |
|
30 | trim: createMethod(3)
|
31 | };
|