You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 28, 2021. It is now read-only.
In the documentation for trim(), it's mentioned that the function will trim all whitespace around delimiters identically to \s:
The characters interpreted as whitespaces are identical to the \s meta character in regular expressions
However, in practice, and inspecting the source of __isCharTrimable(), I can see that it only is trimming the 5 examples characters from the docs, rather than the full list of characters that \s actually matches on. In the MDN Javascript docs, as well as in practice (in the example below in NodeJS), some whitespace characters should be expected to be matched and removed, but aren't.
To Reproduce
This example shows that the values containing whitespace characters not listed in the trim() docs aren't getting removed, but they are when using the regex \s.
constcsvParse=require('csv-parse');/** * First whitespace is 'IDEOGRAPHIC SPACE' (U+3000) * Second whitespace is 'HAIR SPACE' (U+200A) */constinput=`ID,First,Last1234, John,Smith5678,Jane, Doe`;csvParse(input,{columns: true,trim: true},(err,res)=>{if(err){throwerr;}console.log(res);consttrimmed=res.map((r)=>{return{
...r,First: r.First.replace(/^\s+|\s+$/g,''),Last: r.Last.replace(/^\s+|\s+$/g,'')};});console.log(trimmed);});
Additional context
This isn't a case where the code is necessarily broken or incorrect, as it's correctly matching the 5 whitespace characters mentioned in the docs. However, the line in the docs
identical to the \s meta character in regular expressions
incorrectly describes what the output will be.
The text was updated successfully, but these errors were encountered:
Describe the bug
In the documentation for trim(), it's mentioned that the function will trim all whitespace around delimiters identically to
\s
:However, in practice, and inspecting the source of __isCharTrimable(), I can see that it only is trimming the 5 examples characters from the docs, rather than the full list of characters that
\s
actually matches on. In the MDN Javascript docs, as well as in practice (in the example below in NodeJS), some whitespace characters should be expected to be matched and removed, but aren't.To Reproduce
This example shows that the values containing whitespace characters not listed in the trim() docs aren't getting removed, but they are when using the regex
\s
.Additional context
This isn't a case where the code is necessarily broken or incorrect, as it's correctly matching the 5 whitespace characters mentioned in the docs. However, the line in the docs
incorrectly describes what the output will be.
The text was updated successfully, but these errors were encountered: