main
Last change
on this file since d24f17c was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Line | |
---|
1 | var _curry1 =
|
---|
2 | /*#__PURE__*/
|
---|
3 | require("./internal/_curry1.js");
|
---|
4 |
|
---|
5 | var ws = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u2000\u2001\u2002\u2003' + '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028' + '\u2029\uFEFF';
|
---|
6 | var zeroWidth = '\u200b';
|
---|
7 | var hasProtoTrim = typeof String.prototype.trim === 'function';
|
---|
8 | /**
|
---|
9 | * Removes (strips) whitespace from both ends of the string.
|
---|
10 | *
|
---|
11 | * @func
|
---|
12 | * @memberOf R
|
---|
13 | * @since v0.6.0
|
---|
14 | * @category String
|
---|
15 | * @sig String -> String
|
---|
16 | * @param {String} str The string to trim.
|
---|
17 | * @return {String} Trimmed version of `str`.
|
---|
18 | * @example
|
---|
19 | *
|
---|
20 | * R.trim(' xyz '); //=> 'xyz'
|
---|
21 | * R.map(R.trim, R.split(',', 'x, y, z')); //=> ['x', 'y', 'z']
|
---|
22 | */
|
---|
23 |
|
---|
24 | var trim = !hasProtoTrim ||
|
---|
25 | /*#__PURE__*/
|
---|
26 | ws.trim() || !
|
---|
27 | /*#__PURE__*/
|
---|
28 | zeroWidth.trim() ?
|
---|
29 | /*#__PURE__*/
|
---|
30 | _curry1(function trim(str) {
|
---|
31 | var beginRx = new RegExp('^[' + ws + '][' + ws + ']*');
|
---|
32 | var endRx = new RegExp('[' + ws + '][' + ws + ']*$');
|
---|
33 | return str.replace(beginRx, '').replace(endRx, '');
|
---|
34 | }) :
|
---|
35 | /*#__PURE__*/
|
---|
36 | _curry1(function trim(str) {
|
---|
37 | return str.trim();
|
---|
38 | });
|
---|
39 | module.exports = trim; |
---|
Note:
See
TracBrowser
for help on using the repository browser.