<div dir="ltr">That's also true, although I believe `\s` in a regex includes line terminators that trim's concept of whitespace does not.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jun 24, 2019 at 4:15 PM Jacob Pratt <<a href="mailto:jhprattdev@gmail.com">jhprattdev@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">Just thinking about this, the argument that it could be done with regex would also apply to spaces. It's by no means an argument _in favor_, but it clearly wasn't a blocker.<br clear="all"></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jun 24, 2019 at 4:10 PM kai zhu <<a href="mailto:kaizhu256@gmail.com" target="_blank">kaizhu256@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">fyi, a search of the entire markedjs/marked repo shows 2 places where rtrim is used:<div><br></div><div>```js</div><div>// <a href="https://github.com/markedjs/marked/blob/master/lib/marked.js" target="_blank">https://github.com/markedjs/marked/blob/master/lib/marked.js</a>  </div><div><table class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-highlight" style="color:rgb(36,41,46);font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";font-size:14px;box-sizing:border-box;border-collapse:collapse;border-spacing:0px"><tbody style="box-sizing:border-box"><tr style="box-sizing:border-box"><td class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-blob-num" style="font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;box-sizing:border-box;padding:0px;color:rgba(27,31,35,0.298039);font-size:12px;line-height:20px;min-width:50px;text-align:right;vertical-align:top;white-space:nowrap;width:50px"><a href="https://github.com/markedjs/marked/blob/5ba9ba5b93b95096445249c11b31c13f7514137a/lib/marked.js#L227" style="color:inherit;box-sizing:border-box;background-color:transparent;text-decoration-line:none;padding:0px 10px" target="_blank">227</a></td><td class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-blob-code gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-blob-code-inner" style="font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;box-sizing:border-box;padding:0px 10px;line-height:20px;vertical-align:top;font-size:12px;overflow:visible;white-space:pre-wrap">          codeBlockStyle<span class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-pl-k" style="box-sizing:border-box;color:rgb(215,58,73)">:</span> <span class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-pl-s" style="box-sizing:border-box;color:rgb(3,47,98)"><span class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-pl-pds" style="box-sizing:border-box">'</span>indented<span class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-pl-pds" style="box-sizing:border-box">'</span></span>,
</td></tr><tr style="box-sizing:border-box"><td class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-blob-num" style="font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;box-sizing:border-box;padding:0px;color:rgba(27,31,35,0.298039);font-size:12px;line-height:20px;min-width:50px;text-align:right;vertical-align:top;white-space:nowrap;width:50px"><a href="https://github.com/markedjs/marked/blob/5ba9ba5b93b95096445249c11b31c13f7514137a/lib/marked.js#L228" style="color:inherit;box-sizing:border-box;background-color:transparent;text-decoration-line:none;padding:0px 10px" target="_blank">228</a></td><td class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-blob-code gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-blob-code-inner" style="font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;box-sizing:border-box;padding:0px 10px;line-height:20px;vertical-align:top;font-size:12px;overflow:visible;white-space:pre-wrap">          text<span class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-pl-k" style="box-sizing:border-box;color:rgb(215,58,73)">:</span> <span class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-pl-k" style="box-sizing:border-box;color:rgb(215,58,73)">!</span><span class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,92,197)">this</span>.<span class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,92,197)">options</span>.<span class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-pl-smi" style="box-sizing:border-box">pedantic</span>
</td></tr><tr style="box-sizing:border-box"><td class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-blob-num" style="font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;box-sizing:border-box;padding:0px;color:rgba(27,31,35,0.298039);font-size:12px;line-height:20px;min-width:50px;text-align:right;vertical-align:top;white-space:nowrap;width:50px"><a href="https://github.com/markedjs/marked/blob/5ba9ba5b93b95096445249c11b31c13f7514137a/lib/marked.js#L229" style="color:inherit;box-sizing:border-box;background-color:transparent;text-decoration-line:none;padding:0px 10px" target="_blank">229</a></td><td class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-blob-code gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-blob-code-inner" style="font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;box-sizing:border-box;padding:0px 10px;line-height:20px;vertical-align:top;font-size:12px;overflow:visible;white-space:pre-wrap"><span style="background-color:rgb(207,226,243)">            <span class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-pl-k" style="box-sizing:border-box;color:rgb(215,58,73)">?</span> <span class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-pl-en" style="box-sizing:border-box"><span class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-text-bold gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-bg-yellow-light gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-rounded-1 gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-d-inline-block" style="box-sizing:border-box;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;font-weight:600;display:inline-block"><font color="#ff0000">rtrim</font></span></span>(cap, <span class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-pl-s" style="box-sizing:border-box;color:rgb(3,47,98)"><span class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-pl-pds" style="box-sizing:border-box">'</span><span class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-pl-cce" style="box-sizing:border-box">\n</span><span class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-pl-pds" style="box-sizing:border-box">'</span></span>)</span></td></tr><tr style="box-sizing:border-box"><td class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-blob-num" style="font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;box-sizing:border-box;padding:0px;color:rgba(27,31,35,0.298039);font-size:12px;line-height:20px;min-width:50px;text-align:right;vertical-align:top;white-space:nowrap;width:50px"><a href="https://github.com/markedjs/marked/blob/5ba9ba5b93b95096445249c11b31c13f7514137a/lib/marked.js#L230" style="color:inherit;box-sizing:border-box;background-color:transparent;text-decoration-line:none;padding:0px 10px" target="_blank">230</a></td><td class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-blob-code gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-blob-code-inner" style="font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;box-sizing:border-box;padding:0px 10px;line-height:20px;vertical-align:top;font-size:12px;overflow:visible;white-space:pre-wrap">            <span class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-pl-k" style="box-sizing:border-box;color:rgb(215,58,73)">:</span> cap
</td></tr><tr class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-divider" style="box-sizing:border-box"><td class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-blob-num" style="font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;box-sizing:border-box;padding:0px 10px;color:rgba(27,31,35,0.298039);font-size:12px;line-height:15px;min-width:50px;text-align:right;vertical-align:top;white-space:nowrap;width:50px;background-color:rgb(240,245,250);height:18px">…</td><td class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-blob-code" style="box-sizing:border-box;padding:0px 10px;line-height:20px;vertical-align:top;white-space:pre-wrap;background-color:rgb(248,250,253)"></td></tr><tr style="box-sizing:border-box"><td class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-blob-num" style="font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;box-sizing:border-box;padding:0px;color:rgba(27,31,35,0.298039);font-size:12px;line-height:20px;min-width:50px;text-align:right;vertical-align:top;white-space:nowrap;width:50px"><a href="https://github.com/markedjs/marked/blob/5ba9ba5b93b95096445249c11b31c13f7514137a/lib/marked.js#L1425" style="color:inherit;box-sizing:border-box;background-color:transparent;text-decoration-line:none;padding:0px 10px" target="_blank">1425</a></td><td class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-blob-code gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-blob-code-inner" style="font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;box-sizing:border-box;padding:0px 10px;line-height:20px;vertical-align:top;font-size:12px;overflow:visible;white-space:pre-wrap"><span style="background-color:rgb(207,226,243)">      baseUrls[<span class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-pl-s" style="box-sizing:border-box;color:rgb(3,47,98)"><span class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-pl-pds" style="box-sizing:border-box">'</span> <span class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-pl-pds" style="box-sizing:border-box">'</span></span> <span class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-pl-k" style="box-sizing:border-box;color:rgb(215,58,73)">+</span> base] <span class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-pl-k" style="box-sizing:border-box;color:rgb(215,58,73)">=</span> <span class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-pl-en" style="box-sizing:border-box;color:rgb(111,66,193)"><span class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-text-bold gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-bg-yellow-light gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-rounded-1 gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-d-inline-block" style="box-sizing:border-box;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;font-weight:600;display:inline-block">rtrim</span></span>(base, <span class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-pl-s" style="box-sizing:border-box;color:rgb(3,47,98)"><span class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-pl-pds" style="box-sizing:border-box">'</span>/<span class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-pl-pds" style="box-sizing:border-box">'</span></span>, <span class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,92,197)">true</span>);</span></td></tr><tr style="box-sizing:border-box"><td class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-blob-num" style="font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;box-sizing:border-box;padding:0px;color:rgba(27,31,35,0.298039);font-size:12px;line-height:20px;min-width:50px;text-align:right;vertical-align:top;white-space:nowrap;width:50px"><a href="https://github.com/markedjs/marked/blob/5ba9ba5b93b95096445249c11b31c13f7514137a/lib/marked.js#L1426" style="color:inherit;box-sizing:border-box;background-color:transparent;text-decoration-line:none;padding:0px 10px" target="_blank">1426</a></td><td class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-blob-code gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-blob-code-inner" style="font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;box-sizing:border-box;padding:0px 10px;line-height:20px;vertical-align:top;font-size:12px;overflow:visible;white-space:pre-wrap">    }
</td></tr><tr style="box-sizing:border-box"><td class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-blob-num" style="font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;box-sizing:border-box;padding:0px;color:rgba(27,31,35,0.298039);font-size:12px;line-height:20px;min-width:50px;text-align:right;vertical-align:top;white-space:nowrap;width:50px"><a href="https://github.com/markedjs/marked/blob/5ba9ba5b93b95096445249c11b31c13f7514137a/lib/marked.js#L1427" style="color:inherit;box-sizing:border-box;background-color:transparent;text-decoration-line:none;padding:0px 10px" target="_blank">1427</a></td><td class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-blob-code gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-blob-code-inner" style="font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;box-sizing:border-box;padding:0px 10px;line-height:20px;vertical-align:top;font-size:12px;overflow:visible;white-space:pre-wrap">  }
</td></tr><tr style="box-sizing:border-box"><td class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-blob-num" style="font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;box-sizing:border-box;padding:0px;color:rgba(27,31,35,0.298039);font-size:12px;line-height:20px;min-width:50px;text-align:right;vertical-align:top;white-space:nowrap;width:50px"><a href="https://github.com/markedjs/marked/blob/5ba9ba5b93b95096445249c11b31c13f7514137a/lib/marked.js#L1428" style="color:inherit;box-sizing:border-box;background-color:transparent;text-decoration-line:none;padding:0px 10px" target="_blank">1428</a></td><td class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-blob-code gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-blob-code-inner" style="font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;box-sizing:border-box;padding:0px 10px;line-height:20px;vertical-align:top;font-size:12px;overflow:visible;white-space:pre-wrap">  base <span class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-pl-k" style="box-sizing:border-box;color:rgb(215,58,73)">=</span> baseUrls[<span class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-pl-s" style="box-sizing:border-box;color:rgb(3,47,98)"><span class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-pl-pds" style="box-sizing:border-box">'</span> <span class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-pl-pds" style="box-sizing:border-box">'</span></span> <span class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-pl-k" style="box-sizing:border-box;color:rgb(215,58,73)">+</span> base];
</td></tr><tr style="box-sizing:border-box"><td class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-blob-num" style="font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;box-sizing:border-box;padding:0px;color:rgba(27,31,35,0.298039);font-size:12px;line-height:20px;min-width:50px;text-align:right;vertical-align:top;white-space:nowrap;width:50px"><a href="https://github.com/markedjs/marked/blob/5ba9ba5b93b95096445249c11b31c13f7514137a/lib/marked.js#L1429" style="color:inherit;box-sizing:border-box;background-color:transparent;text-decoration-line:none;padding:0px 10px" target="_blank">1429</a></td><td class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-blob-code gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-blob-code-inner" style="font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;box-sizing:border-box;padding:0px 10px;line-height:20px;vertical-align:top;font-size:12px;overflow:visible;white-space:pre-wrap">
</td></tr><tr style="box-sizing:border-box"><td class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-blob-num" style="font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;box-sizing:border-box;padding:0px;color:rgba(27,31,35,0.298039);font-size:12px;line-height:20px;min-width:50px;text-align:right;vertical-align:top;white-space:nowrap;width:50px"><a href="https://github.com/markedjs/marked/blob/5ba9ba5b93b95096445249c11b31c13f7514137a/lib/marked.js#L1430" style="color:inherit;box-sizing:border-box;background-color:transparent;text-decoration-line:none;padding:0px 10px" target="_blank">1430</a></td><td class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-blob-code gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-blob-code-inner" style="font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;box-sizing:border-box;padding:0px 10px;line-height:20px;vertical-align:top;font-size:12px;overflow:visible;white-space:pre-wrap">  <span class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-pl-k" style="box-sizing:border-box;color:rgb(215,58,73)">if</span> (<span class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-pl-smi" style="box-sizing:border-box">href</span>.<span class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,92,197)">slice</span>(<span class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,92,197)">0</span>, <span class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,92,197)">2</span>) <span class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-pl-k" style="box-sizing:border-box;color:rgb(215,58,73)">===</span> <span class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-pl-s" style="box-sizing:border-box;color:rgb(3,47,98)"><span class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-pl-pds" style="box-sizing:border-box">'</span>//<span class="gmail-m_-6219222014314121285gmail-m_-8744077688278869030gmail-pl-pds" style="box-sizing:border-box">'</span></span>) {</td></tr></tbody></table></div><div>```</div><div><br></div><div>only the 1st use-case does what this thread proposes (the 1st trimRight's "\n", while the 2nd behaves differently and is more like nodejs' <font face="courier new, monospace">`require("path").dirname()`</font></div><div><br></div><div>if i were writing the library, i wouldn't have bothered with a helper-function if its only going to show up in 2 [trivial] places.  would've instead inlined two throwaway regexp-expressions, to keep code more-self-contained / less-fragmented:</div><div><br></div><div>```js</div><div>228             text: !this.options.pedantic<br><span style="background-color:rgb(207,226,243)">229                    ? cap.replace((/\n+$/), "")</span><span style="background-color:rgb(255,255,255)"><font color="#ff0000"> // remove trailing "\n" or perhaps just use .trimRight()</font></span><br>230                : cap<br>…<br><span style="background-color:rgb(207,226,243)">1425            baseUrls[' ' + base] = base.replace((/\/[^\/]*$/), "/");</span><span style="background-color:rgb(255,255,255)"><font color="#ff0000"> // get "dirname" of base-url</font></span><br>1426       }</div><div>```<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jun 24, 2019 at 2:27 PM Jacob Pratt <<a href="mailto:jhprattdev@gmail.com" target="_blank">jhprattdev@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>No idea how common of a use case this is; I personally ran across it when reviewing the source code for marked (specifically the [rtrim method]). That example only does characters, not strings, but it's used in the wild by a package with ~2m weekly downloads on npm.</div><div><br></div><div>Of course we wouldn't want `trimStart` to differ from `trimLeft`, they'd all be modified in unison. I just think that symmetry between similar methods is important, and (apparently) has use cases.<br></div><div><br></div><div>[rtrim method]: <a href="https://github.com/markedjs/marked/blob/master/lib/marked.js#L1493-L1517" target="_blank">https://github.com/markedjs/marked/blob/master/lib/marked.js#L1493-L1517</a></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jun 24, 2019 at 12:46 AM Jordan Harband <<a href="mailto:ljharb@gmail.com" target="_blank">ljharb@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr">`trimStart` and `trimEnd` are better-named versions of the very very long-existing `trimLeft` and `trimRight`, which lack this ability, along with ES5's `trim`.<div><br></div><div>It wouldn't make sense for these three to differ.</div><div><br></div><div>It certainly seems like a potential language proposal to add a string argument to all three; however, at what point is that reimplementing `string.replace(/^(foo)+/, '')`, `string.replace(/(foo)+$/, '')`, and `string.replace(/^(foo)+|$(foo)+$/, '')`? How common is the use case to trim matching substrings off of the ends of a string? (the use cases for padding were quite common)</div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Jun 23, 2019 at 12:14 AM Jacob Pratt <<a href="mailto:jhprattdev@gmail.com" target="_blank">jhprattdev@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>`String.prototype.padStart` and `String.prototype.padEnd` accept the string to pad with as their final parameter. Is there any particular reason `String.prototype.trimStart` and `String.prototype.trimEnd` don't do the same? It would be nice to have a parallel, such that `'foo'.padEnd(10, 'bar').trimEnd('bar') === 'foo'`.<br></div><div><br></div><div>References:</div><div>- <a href="https://github.com/tc39/proposal-string-pad-start-end" target="_blank">https://github.com/tc39/proposal-string-pad-start-end</a></div><div>- <a href="https://github.com/tc39/proposal-string-left-right-trim" target="_blank">https://github.com/tc39/proposal-string-left-right-trim</a></div><div><br></div><div>Jacob Pratt</div></div>
_______________________________________________<br>
es-discuss mailing list<br>
<a href="mailto:es-discuss@mozilla.org" target="_blank">es-discuss@mozilla.org</a><br>
<a href="https://mail.mozilla.org/listinfo/es-discuss" rel="noreferrer" target="_blank">https://mail.mozilla.org/listinfo/es-discuss</a><br>
</blockquote></div>
</blockquote></div>
_______________________________________________<br>
es-discuss mailing list<br>
<a href="mailto:es-discuss@mozilla.org" target="_blank">es-discuss@mozilla.org</a><br>
<a href="https://mail.mozilla.org/listinfo/es-discuss" rel="noreferrer" target="_blank">https://mail.mozilla.org/listinfo/es-discuss</a><br>
</blockquote></div>
</blockquote></div>
</blockquote></div>