Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upimplement trimLeft and trimRight #321
Conversation
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
evancz
Aug 2, 2015
Member
Ah, nice find! Why do you use \s in your regex but mozilla uses a more complex sequence in their polyfill for trim? I know they are trimming both ends, but they are detecting more than just \s.
Also, does trim work?
|
Ah, nice find! Why do you use Also, does |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
texastoland
Aug 2, 2015
It looks like the EcmaScript specification defines a couple extended Unicode points as whitespace:
WhiteSpace ::
<TAB>
<VT>
<FF>
<SP>
<NBSP>
<ZWNBSP>
<USP>
For practical purposes they're the same.
texastoland
commented
Aug 2, 2015
|
It looks like the EcmaScript specification defines a couple extended Unicode points as whitespace:
For practical purposes they're the same. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
texastoland
commented
Aug 2, 2015
|
Also the MDN link reports |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
evancz
Aug 2, 2015
Member
Okay, I guess let's go with this. If folks find it odd that trim and trimLeft work on slightly different kinds of whitespace, let's fix that in another PR.
Thanks @jvoigtlaender and @dnalot!
|
Okay, I guess let's go with this. If folks find it odd that Thanks @jvoigtlaender and @dnalot! |
pushed a commit
that referenced
this pull request
Aug 2, 2015
evancz
merged commit b928046
into
elm:master
Aug 2, 2015
1 check passed
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jvoigtlaender
Aug 2, 2015
Contributor
I had modelled it on both stuff I "found on the internet" as well as your implementation of words:
function words(str)
{
return List.fromArray(str.trim().split(/\s+/g));
}Thought it made sense to do trimming by eliminating the same kind of whitespace that is used for finding word boundaries for splitting in that function.
|
I had modelled it on both stuff I "found on the internet" as well as your implementation of function words(str)
{
return List.fromArray(str.trim().split(/\s+/g));
}Thought it made sense to do trimming by eliminating the same kind of whitespace that is used for finding word boundaries for splitting in that function. |
jvoigtlaender commentedAug 1, 2015
... since they are not standard, thus not supported in all browsers.
Addresses https://github.com/elm-lang/core/issues/319 and thus issues like elm/package.elm-lang.org#40.