source: node_modules/ramda/src/trim.js@ d24f17c

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
RevLine 
[d24f17c]1var _curry1 =
2/*#__PURE__*/
3require("./internal/_curry1.js");
4
5var 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';
6var zeroWidth = '\u200b';
7var 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
24var trim = !hasProtoTrim ||
25/*#__PURE__*/
26ws.trim() || !
27/*#__PURE__*/
28zeroWidth.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});
39module.exports = trim;
Note: See TracBrowser for help on using the repository browser.