Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ Partially supported
- [ ] transduce
- [ ] transpose
- [ ] traverse
- [ ] trim
- [x] trim
- [ ] tryCatch
- [ ] type
- [ ] unapply
Expand Down
1 change: 1 addition & 0 deletions ramda/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
from .toPairs import toPairs
from .toPairsIn import toPairsIn
from .toString import toString
from .trim import trim
from .unary import unary
from .union import union
from .unionWith import unionWith
Expand Down
3 changes: 3 additions & 0 deletions ramda/trim.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .private._curry1 import _curry1

trim = _curry1(lambda s: s.strip())
22 changes: 22 additions & 0 deletions test/test_trim.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

import unittest

import ramda as R

"""
https://github.com/ramda/ramda/blob/master/test/T.js
"""

test = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFFHello, World!\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'

class TestT(unittest.TestCase):
def test_trims_a_string(self):
self.assertEqual('xyz', R.trim(' xyz '))

def test_does_not_trim_the_zero_width_space(self):
self.assertEqual('\u200b', R.trim('\u200b'))
self.assertEqual(1, len(R.trim('\u200b')))


if __name__ == '__main__':
unittest.main()