source: node_modules/ramda/es/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.0 KB
Line 
1import _curry1 from "./internal/_curry1.js";
2var 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';
3var zeroWidth = '\u200b';
4var hasProtoTrim = typeof String.prototype.trim === 'function';
5/**
6 * Removes (strips) whitespace from both ends of the string.
7 *
8 * @func
9 * @memberOf R
10 * @since v0.6.0
11 * @category String
12 * @sig String -> String
13 * @param {String} str The string to trim.
14 * @return {String} Trimmed version of `str`.
15 * @example
16 *
17 * R.trim(' xyz '); //=> 'xyz'
18 * R.map(R.trim, R.split(',', 'x, y, z')); //=> ['x', 'y', 'z']
19 */
20
21var trim = !hasProtoTrim ||
22/*#__PURE__*/
23ws.trim() || !
24/*#__PURE__*/
25zeroWidth.trim() ?
26/*#__PURE__*/
27_curry1(function trim(str) {
28 var beginRx = new RegExp('^[' + ws + '][' + ws + ']*');
29 var endRx = new RegExp('[' + ws + '][' + ws + ']*$');
30 return str.replace(beginRx, '').replace(endRx, '');
31}) :
32/*#__PURE__*/
33_curry1(function trim(str) {
34 return str.trim();
35});
36export default trim;
Note: See TracBrowser for help on using the repository browser.