String.prototype.trimRight/trimLeft

Tab Atkins Jr. jackalmage at gmail.com
Tue Mar 17 19:21:14 UTC 2015


On Mon, Mar 16, 2015 at 11:07 PM, Leon Arnott <leonarnott at gmail.com> wrote:
> I believe opinion hasn't shifted since it was discussed
> [previously](https://esdiscuss.org/topic/standardizing-more-de-facto-functions)
> - in short, "show me the cowpath". (But, I've just learned that the IE
> Technical Preview now supports trimLeft/trimRight, so there'll soon be
> support for it in all the major engines. Maybe the cows are there after
> all.)

I use both lstrip() and rstrip() in Bikeshed (a Python project):

https://github.com/tabatkins/bikeshed/search?utf8=%E2%9C%93&q=lstrip&type=Code
https://github.com/tabatkins/bikeshed/search?utf8=%E2%9C%93&q=rstrip&type=Code

In particular, lstrip() is used when I'm separating a key and value; I
don't want to mess with the value much at all, just pull off the
whitespace at the start.  rstrip() is used when I know I don't need to
strip from the left side, because I'm just pulling off newlines or
something, so might as well let the program avoid even trying.

~TJ


More information about the es-discuss mailing list