source: trip-planner-front/node_modules/core-js/internals/string-trim.js@ 1ad8e64

Last change on this file since 1ad8e64 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.1 KB
Line 
1var requireObjectCoercible = require('../internals/require-object-coercible');
2var toString = require('../internals/to-string');
3var whitespaces = require('../internals/whitespaces');
4
5var whitespace = '[' + whitespaces + ']';
6var ltrim = RegExp('^' + whitespace + whitespace + '*');
7var rtrim = RegExp(whitespace + whitespace + '*$');
8
9// `String.prototype.{ trim, trimStart, trimEnd, trimLeft, trimRight }` methods implementation
10var createMethod = function (TYPE) {
11 return function ($this) {
12 var string = toString(requireObjectCoercible($this));
13 if (TYPE & 1) string = string.replace(ltrim, '');
14 if (TYPE & 2) string = string.replace(rtrim, '');
15 return string;
16 };
17};
18
19module.exports = {
20 // `String.prototype.{ trimLeft, trimStart }` methods
21 // https://tc39.es/ecma262/#sec-string.prototype.trimstart
22 start: createMethod(1),
23 // `String.prototype.{ trimRight, trimEnd }` methods
24 // https://tc39.es/ecma262/#sec-string.prototype.trimend
25 end: createMethod(2),
26 // `String.prototype.trim` method
27 // https://tc39.es/ecma262/#sec-string.prototype.trim
28 trim: createMethod(3)
29};
Note: See TracBrowser for help on using the repository browser.