String.prototype.trimRight/trimLeft
I believe opinion hasn't shifted since it was discussed previously - 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 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.) -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150317/cbb354df/attachment.html>
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
- 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):
tabatkins/bikeshed/search?utf8=✓&q=lstrip&type=Code, tabatkins/bikeshed/search?utf8=✓&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.
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
Right, so from the several feedback I had so far, it seems it will make sense just to add to ES7? In this case we'll be able to polyfill now, the spec'ing it will be trivial (I'll add the spec).
I guess we just need to confirm it's good to go to ES7?
Dmitry
Right, so from the several feedback I had so far, it seems it will make sense just to add to ES7? In this case we'll be able to polyfill now, the spec'ing it will be trivial (I'll add the spec). I guess we just need to confirm it's good to go to ES7? Dmitry On Tue, Mar 17, 2015 at 12:21 PM, Tab Atkins Jr. <jackalmage at gmail.com> wrote: > 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150317/22183868/attachment.html>
Yeah, this seems like a shoe-in for ES7. It will probably be able to advance through the stages very quickly given that it already has three (four?) shipping implementations.
Someone just needs to write up a formal spec (using Ecmarkdown! ^_^) and test262 tests. The only snag would be if you find non-interoperable behavior between browsers in the course of writing those tests, and need to get some patches accepted before you can reach stage 4.
Yeah, this seems like a shoe-in for ES7. It will probably be able to advance through the stages very quickly given that it already has three (four?) shipping implementations. Someone just needs to write up a formal spec (using Ecmarkdown! ^_^) and test262 tests. The only snag would be if you find non-interoperable behavior between browsers in the course of writing those tests, and need to get some patches accepted before you can reach stage 4. From: es-discuss [mailto:es-discuss-bounces at mozilla.org] On Behalf Of Dmitry Soshnikov Sent: Wednesday, March 18, 2015 05:02 To: Tab Atkins Jr. Cc: es-discuss Subject: Re: String.prototype.trimRight/trimLeft Right, so from the several feedback I had so far, it seems it will make sense just to add to ES7? In this case we'll be able to polyfill now, the spec'ing it will be trivial (I'll add the spec). I guess we just need to confirm it's good to go to ES7? Dmitry On Tue, Mar 17, 2015 at 12:21 PM, Tab Atkins Jr. <jackalmage at gmail.com<mailto:jackalmage at gmail.com>> wrote: On Mon, Mar 16, 2015 at 11:07 PM, Leon Arnott <leonarnott at gmail.com<mailto: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 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150318/f605f542/attachment.html>
Sounds good. Yeah, I'll spec it, and add the test.
Dmitry
Sounds good. Yeah, I'll spec it, and add the test. Dmitry On Tuesday, March 17, 2015, Domenic Denicola <d at domenic.me> wrote: > Yeah, this seems like a shoe-in for ES7. It will probably be able to > advance through the stages *very* quickly given that it already has three > (four?) shipping implementations. > > > > Someone just needs to write up a formal spec (using Ecmarkdown! ^_^) and > test262 tests. The only snag would be if you find non-interoperable > behavior between browsers in the course of writing those tests, and need to > get some patches accepted before you can reach stage 4. > > > > *From:* es-discuss [mailto:es-discuss-bounces at mozilla.org > <javascript:_e(%7B%7D,'cvml','es-discuss-bounces at mozilla.org');>] *On > Behalf Of *Dmitry Soshnikov > *Sent:* Wednesday, March 18, 2015 05:02 > *To:* Tab Atkins Jr. > *Cc:* es-discuss > *Subject:* Re: String.prototype.trimRight/trimLeft > > > > Right, so from the several feedback I had so far, it seems it will make > sense just to add to ES7? In this case we'll be able to polyfill now, the > spec'ing it will be trivial (I'll add the spec). > > > > I guess we just need to confirm it's good to go to ES7? > > > > Dmitry > > > > On Tue, Mar 17, 2015 at 12:21 PM, Tab Atkins Jr. <jackalmage at gmail.com > <javascript:_e(%7B%7D,'cvml','jackalmage at gmail.com');>> wrote: > > On Mon, Mar 16, 2015 at 11:07 PM, Leon Arnott <leonarnott at gmail.com > <javascript:_e(%7B%7D,'cvml','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 > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150317/319fc406/attachment.html>
OK, the spec is here: gist.github.com/DmitrySoshnikov/65a2070477fffb465048 Will appreciate review and corrections if needed.
Dmitry
OK, the spec is here: https://gist.github.com/DmitrySoshnikov/65a2070477fffb465048 Will appreciate review and corrections if needed. Dmitry On Tue, Mar 17, 2015 at 7:36 PM, Dmitry Soshnikov < dmitry.soshnikov at gmail.com> wrote: > Sounds good. Yeah, I'll spec it, and add the test. > > Dmitry > > > On Tuesday, March 17, 2015, Domenic Denicola <d at domenic.me> wrote: > >> Yeah, this seems like a shoe-in for ES7. It will probably be able to >> advance through the stages *very* quickly given that it already has >> three (four?) shipping implementations. >> >> >> >> Someone just needs to write up a formal spec (using Ecmarkdown! ^_^) and >> test262 tests. The only snag would be if you find non-interoperable >> behavior between browsers in the course of writing those tests, and need to >> get some patches accepted before you can reach stage 4. >> >> >> >> *From:* es-discuss [mailto:es-discuss-bounces at mozilla.org] *On Behalf Of >> *Dmitry Soshnikov >> *Sent:* Wednesday, March 18, 2015 05:02 >> *To:* Tab Atkins Jr. >> *Cc:* es-discuss >> *Subject:* Re: String.prototype.trimRight/trimLeft >> >> >> >> Right, so from the several feedback I had so far, it seems it will make >> sense just to add to ES7? In this case we'll be able to polyfill now, the >> spec'ing it will be trivial (I'll add the spec). >> >> >> >> I guess we just need to confirm it's good to go to ES7? >> >> >> >> Dmitry >> >> >> >> On Tue, Mar 17, 2015 at 12:21 PM, Tab Atkins Jr. <jackalmage at gmail.com> >> wrote: >> >> 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 >> >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150318/7c7e1eb7/attachment-0001.html>
Will somebody be so kind to present this on the following meeting for me, I don't have an ability to attend, and the change is pretty small (July 28th, 2015)?
People were asking, and we'd like to polyfill it instead of doing regexp replaces. Again the spec is here: gist.github.com/DmitrySoshnikov/65a2070477fffb465048
Will somebody be so kind to present this on the following meeting for me, I don't have an ability to attend, and the change is pretty small (July 28th, 2015)? People were asking, and we'd like to polyfill it instead of doing regexp replaces. Again the spec is here: https://gist.github.com/DmitrySoshnikov/65a2070477fffb465048 Thanks! Dmitry On Wed, Mar 18, 2015 at 2:26 PM, Dmitry Soshnikov < dmitry.soshnikov at gmail.com> wrote: > OK, the spec is here: > https://gist.github.com/DmitrySoshnikov/65a2070477fffb465048 Will > appreciate review and corrections if needed. > > Dmitry > > On Tue, Mar 17, 2015 at 7:36 PM, Dmitry Soshnikov < > dmitry.soshnikov at gmail.com> wrote: > >> Sounds good. Yeah, I'll spec it, and add the test. >> >> Dmitry >> >> >> On Tuesday, March 17, 2015, Domenic Denicola <d at domenic.me> wrote: >> >>> Yeah, this seems like a shoe-in for ES7. It will probably be able to >>> advance through the stages *very* quickly given that it already has >>> three (four?) shipping implementations. >>> >>> >>> >>> Someone just needs to write up a formal spec (using Ecmarkdown! ^_^) and >>> test262 tests. The only snag would be if you find non-interoperable >>> behavior between browsers in the course of writing those tests, and need to >>> get some patches accepted before you can reach stage 4. >>> >>> >>> >>> *From:* es-discuss [mailto:es-discuss-bounces at mozilla.org] *On Behalf >>> Of *Dmitry Soshnikov >>> *Sent:* Wednesday, March 18, 2015 05:02 >>> *To:* Tab Atkins Jr. >>> *Cc:* es-discuss >>> *Subject:* Re: String.prototype.trimRight/trimLeft >>> >>> >>> >>> Right, so from the several feedback I had so far, it seems it will make >>> sense just to add to ES7? In this case we'll be able to polyfill now, the >>> spec'ing it will be trivial (I'll add the spec). >>> >>> >>> >>> I guess we just need to confirm it's good to go to ES7? >>> >>> >>> >>> Dmitry >>> >>> >>> >>> On Tue, Mar 17, 2015 at 12:21 PM, Tab Atkins Jr. <jackalmage at gmail.com> >>> wrote: >>> >>> 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 >>> >>> >>> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150720/967b3e96/attachment-0001.html>
These methods should be called trimStart and trimEnd. Determining which parts of the string are left and right would require running the Unicode Bidirectional Algorithm, and that’s probably not intended here.
These methods should be called trimStart and trimEnd. Determining which parts of the string are left and right would require running the Unicode Bidirectional Algorithm, and that’s probably not intended here. Norbert > On Jul 20, 2015, at 15:09 , Dmitry Soshnikov <dmitry.soshnikov at gmail.com> wrote: > > Will somebody be so kind to present this on the following meeting for me, I don't have an ability to attend, and the change is pretty small (July 28th, 2015)? > > People were asking, and we'd like to polyfill it instead of doing regexp replaces. Again the spec is here: https://gist.github.com/DmitrySoshnikov/65a2070477fffb465048 > > Thanks! > > Dmitry > > On Wed, Mar 18, 2015 at 2:26 PM, Dmitry Soshnikov <dmitry.soshnikov at gmail.com> wrote: > OK, the spec is here: https://gist.github.com/DmitrySoshnikov/65a2070477fffb465048 Will appreciate review and corrections if needed. > > Dmitry > > On Tue, Mar 17, 2015 at 7:36 PM, Dmitry Soshnikov <dmitry.soshnikov at gmail.com> wrote: > Sounds good. Yeah, I'll spec it, and add the test. > > Dmitry > > > On Tuesday, March 17, 2015, Domenic Denicola <d at domenic.me> wrote: > Yeah, this seems like a shoe-in for ES7. It will probably be able to advance through the stages very quickly given that it already has three (four?) shipping implementations. > > > > Someone just needs to write up a formal spec (using Ecmarkdown! ^_^) and test262 tests. The only snag would be if you find non-interoperable behavior between browsers in the course of writing those tests, and need to get some patches accepted before you can reach stage 4. > > > > From: es-discuss [mailto:es-discuss-bounces at mozilla.org] On Behalf Of Dmitry Soshnikov > Sent: Wednesday, March 18, 2015 05:02 > To: Tab Atkins Jr. > Cc: es-discuss > Subject: Re: String.prototype.trimRight/trimLeft > > > > Right, so from the several feedback I had so far, it seems it will make sense just to add to ES7? In this case we'll be able to polyfill now, the spec'ing it will be trivial (I'll add the spec). > > > > I guess we just need to confirm it's good to go to ES7? > > > > Dmitry > > > > On Tue, Mar 17, 2015 at 12:21 PM, Tab Atkins Jr. <jackalmage at gmail.com> wrote: > > 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 > > > > > > _______________________________________________ > es-discuss mailing list > es-discuss at mozilla.org > https://mail.mozilla.org/listinfo/es-discuss
On the contrary -"left" always begins at index 0 - "start" is sometimes index 0, sometimes index (length - 1). I think "left" and "right" are the right names; "start" and "end" would require unicode bidirectional stuff.
On the contrary -"left" always begins at index 0 - "start" is sometimes index 0, sometimes index (length - 1). I think "left" and "right" are the right names; "start" and "end" would require unicode bidirectional stuff. On Mon, Jul 20, 2015 at 11:25 PM, Norbert Lindenberg < ecmascript at lindenbergsoftware.com> wrote: > These methods should be called trimStart and trimEnd. Determining which > parts of the string are left and right would require running the Unicode > Bidirectional Algorithm, and that’s probably not intended here. > > Norbert > > > > On Jul 20, 2015, at 15:09 , Dmitry Soshnikov <dmitry.soshnikov at gmail.com> > wrote: > > > > Will somebody be so kind to present this on the following meeting for > me, I don't have an ability to attend, and the change is pretty small (July > 28th, 2015)? > > > > People were asking, and we'd like to polyfill it instead of doing regexp > replaces. Again the spec is here: > https://gist.github.com/DmitrySoshnikov/65a2070477fffb465048 > > > > Thanks! > > > > Dmitry > > > > On Wed, Mar 18, 2015 at 2:26 PM, Dmitry Soshnikov < > dmitry.soshnikov at gmail.com> wrote: > > OK, the spec is here: > https://gist.github.com/DmitrySoshnikov/65a2070477fffb465048 Will > appreciate review and corrections if needed. > > > > Dmitry > > > > On Tue, Mar 17, 2015 at 7:36 PM, Dmitry Soshnikov < > dmitry.soshnikov at gmail.com> wrote: > > Sounds good. Yeah, I'll spec it, and add the test. > > > > Dmitry > > > > > > On Tuesday, March 17, 2015, Domenic Denicola <d at domenic.me> wrote: > > Yeah, this seems like a shoe-in for ES7. It will probably be able to > advance through the stages very quickly given that it already has three > (four?) shipping implementations. > > > > > > > > Someone just needs to write up a formal spec (using Ecmarkdown! ^_^) and > test262 tests. The only snag would be if you find non-interoperable > behavior between browsers in the course of writing those tests, and need to > get some patches accepted before you can reach stage 4. > > > > > > > > From: es-discuss [mailto:es-discuss-bounces at mozilla.org] On Behalf Of > Dmitry Soshnikov > > Sent: Wednesday, March 18, 2015 05:02 > > To: Tab Atkins Jr. > > Cc: es-discuss > > Subject: Re: String.prototype.trimRight/trimLeft > > > > > > > > Right, so from the several feedback I had so far, it seems it will make > sense just to add to ES7? In this case we'll be able to polyfill now, the > spec'ing it will be trivial (I'll add the spec). > > > > > > > > I guess we just need to confirm it's good to go to ES7? > > > > > > > > Dmitry > > > > > > > > On Tue, Mar 17, 2015 at 12:21 PM, Tab Atkins Jr. <jackalmage at gmail.com> > wrote: > > > > 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 > > > > > > > > > > > > _______________________________________________ > > es-discuss mailing list > > es-discuss at mozilla.org > > https://mail.mozilla.org/listinfo/es-discuss > > _______________________________________________ > es-discuss mailing list > es-discuss at mozilla.org > https://mail.mozilla.org/listinfo/es-discuss > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150720/dfd46466/attachment-0001.html>
They're already shipping with the "wrong" names in every browser.
They're already shipping with the "wrong" names in every browser. From: Norbert Lindenberg <ecmascript at lindenbergsoftware.com> Sent: Jul 20, 2015 23:25 To: Dmitry Soshnikov Cc: Norbert Lindenberg; Domenic Denicola; es-discuss Subject: Re: String.prototype.trimRight/trimLeft These methods should be called trimStart and trimEnd. Determining which parts of the string are left and right would require running the Unicode Bidirectional Algorithm, and that’s probably not intended here. Norbert > On Jul 20, 2015, at 15:09 , Dmitry Soshnikov <dmitry.soshnikov at gmail.com<mailto:dmitry.soshnikov at gmail.com>> wrote: > > Will somebody be so kind to present this on the following meeting for me, I don't have an ability to attend, and the change is pretty small (July 28th, 2015)? > > People were asking, and we'd like to polyfill it instead of doing regexp replaces. Again the spec is here: https://gist.github.com/DmitrySoshnikov/65a2070477fffb465048 > > Thanks! > > Dmitry > > On Wed, Mar 18, 2015 at 2:26 PM, Dmitry Soshnikov <dmitry.soshnikov at gmail.com<mailto:dmitry.soshnikov at gmail.com>> wrote: > OK, the spec is here: https://gist.github.com/DmitrySoshnikov/65a2070477fffb465048 Will appreciate review and corrections if needed. > > Dmitry > > On Tue, Mar 17, 2015 at 7:36 PM, Dmitry Soshnikov <dmitry.soshnikov at gmail.com<mailto:dmitry.soshnikov at gmail.com>> wrote: > Sounds good. Yeah, I'll spec it, and add the test. > > Dmitry > > > On Tuesday, March 17, 2015, Domenic Denicola <d at domenic.me<mailto:d at domenic.me>> wrote: > Yeah, this seems like a shoe-in for ES7. It will probably be able to advance through the stages very quickly given that it already has three (four?) shipping implementations. > > > > Someone just needs to write up a formal spec (using Ecmarkdown! ^_^) and test262 tests. The only snag would be if you find non-interoperable behavior between browsers in the course of writing those tests, and need to get some patches accepted before you can reach stage 4. > > > > From: es-discuss [mailto:es-discuss-bounces at mozilla.org<mailto:es-discuss-bounces at mozilla.org>] On Behalf Of Dmitry Soshnikov > Sent: Wednesday, March 18, 2015 05:02 > To: Tab Atkins Jr. > Cc: es-discuss > Subject: Re: String.prototype.trimRight/trimLeft > > > > Right, so from the several feedback I had so far, it seems it will make sense just to add to ES7? In this case we'll be able to polyfill now, the spec'ing it will be trivial (I'll add the spec). > > > > I guess we just need to confirm it's good to go to ES7? > > > > Dmitry > > > > On Tue, Mar 17, 2015 at 12:21 PM, Tab Atkins Jr. <jackalmage at gmail.com<mailto:jackalmage at gmail.com>> wrote: > > On Mon, Mar 16, 2015 at 11:07 PM, Leon Arnott <leonarnott at gmail.com<mailto: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 > > > > > > _______________________________________________ > es-discuss mailing list > es-discuss at mozilla.org<mailto:es-discuss at mozilla.org> > https://mail.mozilla.org/listinfo/es-discuss -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150721/ddabd3a5/attachment.html>
In which coordinate system?
In which coordinate system? Norbert > On Jul 20, 2015, at 23:28 , Jordan Harband <ljharb at gmail.com> wrote: > > On the contrary -"left" always begins at index 0 - "start" is sometimes index 0, sometimes index (length - 1). I think "left" and "right" are the right names; "start" and "end" would require unicode bidirectional stuff. > > On Mon, Jul 20, 2015 at 11:25 PM, Norbert Lindenberg <ecmascript at lindenbergsoftware.com> wrote: > These methods should be called trimStart and trimEnd. Determining which parts of the string are left and right would require running the Unicode Bidirectional Algorithm, and that’s probably not intended here. > > Norbert > > > > On Jul 20, 2015, at 15:09 , Dmitry Soshnikov <dmitry.soshnikov at gmail.com> wrote: > > > > Will somebody be so kind to present this on the following meeting for me, I don't have an ability to attend, and the change is pretty small (July 28th, 2015)? > > > > People were asking, and we'd like to polyfill it instead of doing regexp replaces. Again the spec is here: https://gist.github.com/DmitrySoshnikov/65a2070477fffb465048 > > > > Thanks! > > > > Dmitry > > > > On Wed, Mar 18, 2015 at 2:26 PM, Dmitry Soshnikov <dmitry.soshnikov at gmail.com> wrote: > > OK, the spec is here: https://gist.github.com/DmitrySoshnikov/65a2070477fffb465048 Will appreciate review and corrections if needed. > > > > Dmitry > > > > On Tue, Mar 17, 2015 at 7:36 PM, Dmitry Soshnikov <dmitry.soshnikov at gmail.com> wrote: > > Sounds good. Yeah, I'll spec it, and add the test. > > > > Dmitry > > > > > > On Tuesday, March 17, 2015, Domenic Denicola <d at domenic.me> wrote: > > Yeah, this seems like a shoe-in for ES7. It will probably be able to advance through the stages very quickly given that it already has three (four?) shipping implementations. > > > > > > > > Someone just needs to write up a formal spec (using Ecmarkdown! ^_^) and test262 tests. The only snag would be if you find non-interoperable behavior between browsers in the course of writing those tests, and need to get some patches accepted before you can reach stage 4. > > > > > > > > From: es-discuss [mailto:es-discuss-bounces at mozilla.org] On Behalf Of Dmitry Soshnikov > > Sent: Wednesday, March 18, 2015 05:02 > > To: Tab Atkins Jr. > > Cc: es-discuss > > Subject: Re: String.prototype.trimRight/trimLeft > > > > > > > > Right, so from the several feedback I had so far, it seems it will make sense just to add to ES7? In this case we'll be able to polyfill now, the spec'ing it will be trivial (I'll add the spec). > > > > > > > > I guess we just need to confirm it's good to go to ES7? > > > > > > > > Dmitry > > > > > > > > On Tue, Mar 17, 2015 at 12:21 PM, Tab Atkins Jr. <jackalmage at gmail.com> wrote: > > > > 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 > > > > > > > > > > > > _______________________________________________ > > es-discuss mailing list > > es-discuss at mozilla.org > > https://mail.mozilla.org/listinfo/es-discuss > > _______________________________________________ > es-discuss mailing list > es-discuss at mozilla.org > https://mail.mozilla.org/listinfo/es-discuss >
On Jul 20, 2015, at 23:29 , Domenic Denicola <d at domenic.me> wrote:
They're already shipping with the "wrong" names in every browser.
That’s very sad, because they’re wrong, not “wrong”.
That’s very sad, because they’re wrong, not “wrong”. Norbert > On Jul 20, 2015, at 23:29 , Domenic Denicola <d at domenic.me> wrote: > > They're already shipping with the "wrong" names in every browser. > > > > From: Norbert Lindenberg <ecmascript at lindenbergsoftware.com> > Sent: Jul 20, 2015 23:25 > To: Dmitry Soshnikov > Cc: Norbert Lindenberg; Domenic Denicola; es-discuss > Subject: Re: String.prototype.trimRight/trimLeft > > These methods should be called trimStart and trimEnd. Determining which parts of the string are left and right would require running the Unicode Bidirectional Algorithm, and that’s probably not intended here. > > Norbert > > > > On Jul 20, 2015, at 15:09 , Dmitry Soshnikov <dmitry.soshnikov at gmail.com> wrote: > > > > Will somebody be so kind to present this on the following meeting for me, I don't have an ability to attend, and the change is pretty small (July 28th, 2015)? > > > > People were asking, and we'd like to polyfill it instead of doing regexp replaces. Again the spec is here: https://gist.github.com/DmitrySoshnikov/65a2070477fffb465048 > > > > Thanks! > > > > Dmitry > > > > On Wed, Mar 18, 2015 at 2:26 PM, Dmitry Soshnikov <dmitry.soshnikov at gmail.com> wrote: > > OK, the spec is here: https://gist.github.com/DmitrySoshnikov/65a2070477fffb465048 Will appreciate review and corrections if needed. > > > > Dmitry > > > > On Tue, Mar 17, 2015 at 7:36 PM, Dmitry Soshnikov <dmitry.soshnikov at gmail.com> wrote: > > Sounds good. Yeah, I'll spec it, and add the test. > > > > Dmitry > > > > > > On Tuesday, March 17, 2015, Domenic Denicola <d at domenic.me> wrote: > > Yeah, this seems like a shoe-in for ES7. It will probably be able to advance through the stages very quickly given that it already has three (four?) shipping implementations. > > > > > > > > Someone just needs to write up a formal spec (using Ecmarkdown! ^_^) and test262 tests. The only snag would be if you find non-interoperable behavior between browsers in the course of writing those tests, and need to get some patches accepted before you can reach stage 4. > > > > > > > > From: es-discuss [mailto:es-discuss-bounces at mozilla.org] On Behalf Of Dmitry Soshnikov > > Sent: Wednesday, March 18, 2015 05:02 > > To: Tab Atkins Jr. > > Cc: es-discuss > > Subject: Re: String.prototype.trimRight/trimLeft > > > > > > > > Right, so from the several feedback I had so far, it seems it will make sense just to add to ES7? In this case we'll be able to polyfill now, the spec'ing it will be trivial (I'll add the spec). > > > > > > > > I guess we just need to confirm it's good to go to ES7? > > > > > > > > Dmitry > > > > > > > > On Tue, Mar 17, 2015 at 12:21 PM, Tab Atkins Jr. <jackalmage at gmail.com> wrote: > > > > 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 > > > > > > > > > > > > _______________________________________________ > > es-discuss mailing list > > es-discuss at mozilla.org > > https://mail.mozilla.org/listinfo/es-discuss >
Le 21 juil. 2015 à 08:28, Jordan Harband <ljharb at gmail.com> a écrit :
On the contrary -"left" always begins at index 0 - "start" is sometimes index 0, sometimes index (length - 1).
Counter-example: ES6 methods String#startsWith
and String#endsWith
are named correctly.
I think "left" and "right" are the right names; "start" and "end" would require unicode bidirectional stuff.
No, because characters in Unicode strings are ordered logically, not visually.
> Le 21 juil. 2015 à 08:28, Jordan Harband <ljharb at gmail.com> a écrit : > > On the contrary -"left" always begins at index 0 - "start" is sometimes index 0, sometimes index (length - 1). Counter-example: ES6 methods `String#startsWith` and `String#endsWith` are named correctly. > I think "left" and "right" are the right names; "start" and "end" would require unicode bidirectional stuff. No, because characters in Unicode strings are ordered logically, not visually. —Claude
OK, it was added to the agenda for the next meeting (will be presented
by Sebastian Markbage), so can be discussed in detail. I agree that
"start", and "end" are now probably better fit (because of i18n, and a
strong correlation with "startsWith" and "endsWith"). We can probably
ignore the de-facto shipped in browsers, they will just implement in
addition trimStart
and trimEnd
, and eventually deprecate the "right"
and "left".
Dmitry
OK, it was added to the agenda for the next meeting (will be presented by Sebastian Markbage), so can be discussed in detail. I agree that "start", and "end" are now probably better fit (because of i18n, and a strong correlation with "startsWith" and "endsWith"). We can probably ignore the de-facto shipped in browsers, they will just implement in addition `trimStart` and `trimEnd`, and eventually deprecate the "right" and "left". Dmitry On Tue, Jul 21, 2015 at 12:02 AM, Claude Pache <claude.pache at gmail.com> wrote: > > > Le 21 juil. 2015 à 08:28, Jordan Harband <ljharb at gmail.com> a écrit : > > > > On the contrary -"left" always begins at index 0 - "start" is sometimes > index 0, sometimes index (length - 1). > > Counter-example: ES6 methods `String#startsWith` and `String#endsWith` are > named correctly. > > > I think "left" and "right" are the right names; "start" and "end" would > require unicode bidirectional stuff. > > No, because characters in Unicode strings are ordered logically, not > visually. > > —Claude > > _______________________________________________ > es-discuss mailing list > es-discuss at mozilla.org > https://mail.mozilla.org/listinfo/es-discuss > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150727/5329ffab/attachment.html>
In the wild I've seen ltrim rtrim which are variations of trimLeft and trimRight and padLeft padRight or lpad, rpad for other forms. For stings I think of left and right as leading and trailing and think of start and end as more position indicators of like slice or a range.
In the wild I've seen ltrim rtrim which are variations of trimLeft and trimRight and padLeft padRight or lpad, rpad for other forms. For stings I think of left and right as leading and trailing and think of start and end as more position indicators of like slice or a range. -JDD On Mon, Jul 27, 2015 at 4:55 PM, Dmitry Soshnikov < dmitry.soshnikov at gmail.com> wrote: > OK, it was added to the agenda for the next meeting (will be presented > by Sebastian Markbage), so can be discussed in detail. I agree that > "start", and "end" are now probably better fit (because of i18n, and a > strong correlation with "startsWith" and "endsWith"). We can probably > ignore the de-facto shipped in browsers, they will just implement in > addition `trimStart` and `trimEnd`, and eventually deprecate the "right" > and "left". > > Dmitry > > On Tue, Jul 21, 2015 at 12:02 AM, Claude Pache <claude.pache at gmail.com> > wrote: > >> >> > Le 21 juil. 2015 à 08:28, Jordan Harband <ljharb at gmail.com> a écrit : >> > >> > On the contrary -"left" always begins at index 0 - "start" is sometimes >> index 0, sometimes index (length - 1). >> >> Counter-example: ES6 methods `String#startsWith` and `String#endsWith` >> are named correctly. >> >> > I think "left" and "right" are the right names; "start" and "end" would >> require unicode bidirectional stuff. >> >> No, because characters in Unicode strings are ordered logically, not >> visually. >> >> —Claude >> >> _______________________________________________ >> es-discuss mailing list >> es-discuss at mozilla.org >> https://mail.mozilla.org/listinfo/es-discuss >> > > > _______________________________________________ > es-discuss mailing list > es-discuss at mozilla.org > https://mail.mozilla.org/listinfo/es-discuss > > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150727/82295d27/attachment.html>
Another set of very handy functions that in Java are provided by libraries
such as Guava or Apache Commons and in C# are built in, are
String.isNullOrEmpty(aStr)
and String.IsNullOrWhiteSpace(aStr)
.
Would be nice if they ES Strings had them too.
Another set of very handy functions that in Java are provided by libraries such as Guava or Apache Commons and in C# are built in, are `String.isNullOrEmpty(aStr)` and `String.IsNullOrWhiteSpace(aStr)`. Would be nice if they ES Strings had them too. On Tue, Jul 28, 2015 at 10:15 AM John-David Dalton < john.david.dalton at gmail.com> wrote: > In the wild I've seen ltrim rtrim which are variations of trimLeft and > trimRight and padLeft padRight or lpad, rpad for other forms. For stings I > think of left and right as leading and trailing and think of start and end > as more position indicators of like slice or a range. > > > -JDD > > On Mon, Jul 27, 2015 at 4:55 PM, Dmitry Soshnikov < > dmitry.soshnikov at gmail.com> wrote: > >> OK, it was added to the agenda for the next meeting (will be presented >> by Sebastian Markbage), so can be discussed in detail. I agree that >> "start", and "end" are now probably better fit (because of i18n, and a >> strong correlation with "startsWith" and "endsWith"). We can probably >> ignore the de-facto shipped in browsers, they will just implement in >> addition `trimStart` and `trimEnd`, and eventually deprecate the "right" >> and "left". >> >> Dmitry >> >> On Tue, Jul 21, 2015 at 12:02 AM, Claude Pache <claude.pache at gmail.com> >> wrote: >> >>> >>> > Le 21 juil. 2015 à 08:28, Jordan Harband <ljharb at gmail.com> a écrit : >>> > >>> > On the contrary -"left" always begins at index 0 - "start" is >>> sometimes index 0, sometimes index (length - 1). >>> >>> Counter-example: ES6 methods `String#startsWith` and `String#endsWith` >>> are named correctly. >>> >>> > I think "left" and "right" are the right names; "start" and "end" >>> would require unicode bidirectional stuff. >>> >>> No, because characters in Unicode strings are ordered logically, not >>> visually. >>> >>> —Claude >>> >>> _______________________________________________ >>> es-discuss mailing list >>> es-discuss at mozilla.org >>> https://mail.mozilla.org/listinfo/es-discuss >>> >> >> >> _______________________________________________ >> es-discuss mailing list >> es-discuss at mozilla.org >> https://mail.mozilla.org/listinfo/es-discuss >> >> > _______________________________________________ > es-discuss mailing list > es-discuss at mozilla.org > https://mail.mozilla.org/listinfo/es-discuss > -- Best regards, Behrang Saeedzadeh -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150729/27af7f19/attachment-0001.html>
I can't remember last time when I would need isNullOrEmpty
-
Boolean('') and Boolean(null) evaluates to false. And if (str)
handles any case with consistent types.
String.isNullOrEmpty = (a)=>(typeof a === 'string' || a === null) && !a;
Anyway - native isNullOrWhiteSpace would be probably be useful only to reduce GC pressure, because it's easily polyfilled.
String.isNullOrWhiteSpace = (a)=>a === null ? true : typeof a === 'string' && !a.trim();
2015-07-29 13:27 GMT+02:00 Behrang Saeedzadeh <behrangsa at gmail.com>:
I can't remember last time when I would need `isNullOrEmpty` - Boolean('') and Boolean(null) evaluates to false. And `if (str)` handles any case with consistent types. String.isNullOrEmpty = (a)=>(typeof a === 'string' || a === null) && !a; Anyway - native isNullOrWhiteSpace would be probably be useful only to reduce GC pressure, because it's easily polyfilled. String.isNullOrWhiteSpace = (a)=>a === null ? true : typeof a === 'string' && !a.trim(); 2015-07-29 13:27 GMT+02:00 Behrang Saeedzadeh <behrangsa at gmail.com>: > Another set of very handy functions that in Java are provided by libraries > such as Guava or Apache Commons and in C# are built in, are > `String.isNullOrEmpty(aStr)` and `String.IsNullOrWhiteSpace(aStr)`. > > Would be nice if they ES Strings had them too. > > On Tue, Jul 28, 2015 at 10:15 AM John-David Dalton > <john.david.dalton at gmail.com> wrote: >> >> In the wild I've seen ltrim rtrim which are variations of trimLeft and >> trimRight and padLeft padRight or lpad, rpad for other forms. For stings I >> think of left and right as leading and trailing and think of start and end >> as more position indicators of like slice or a range. >> >> >> -JDD >> >> On Mon, Jul 27, 2015 at 4:55 PM, Dmitry Soshnikov >> <dmitry.soshnikov at gmail.com> wrote: >>> >>> OK, it was added to the agenda for the next meeting (will be presented by >>> Sebastian Markbage), so can be discussed in detail. I agree that "start", >>> and "end" are now probably better fit (because of i18n, and a strong >>> correlation with "startsWith" and "endsWith"). We can probably ignore the >>> de-facto shipped in browsers, they will just implement in addition >>> `trimStart` and `trimEnd`, and eventually deprecate the "right" and "left". >>> >>> Dmitry >>> >>> On Tue, Jul 21, 2015 at 12:02 AM, Claude Pache <claude.pache at gmail.com> >>> wrote: >>>> >>>> >>>> > Le 21 juil. 2015 à 08:28, Jordan Harband <ljharb at gmail.com> a écrit : >>>> > >>>> > On the contrary -"left" always begins at index 0 - "start" is >>>> > sometimes index 0, sometimes index (length - 1). >>>> >>>> Counter-example: ES6 methods `String#startsWith` and `String#endsWith` >>>> are named correctly. >>>> >>>> > I think "left" and "right" are the right names; "start" and "end" >>>> > would require unicode bidirectional stuff. >>>> >>>> No, because characters in Unicode strings are ordered logically, not >>>> visually. >>>> >>>> —Claude >>>> >>>> _______________________________________________ >>>> es-discuss mailing list >>>> es-discuss at mozilla.org >>>> https://mail.mozilla.org/listinfo/es-discuss >>> >>> >>> >>> _______________________________________________ >>> es-discuss mailing list >>> es-discuss at mozilla.org >>> https://mail.mozilla.org/listinfo/es-discuss >>> >> >> _______________________________________________ >> es-discuss mailing list >> es-discuss at mozilla.org >> https://mail.mozilla.org/listinfo/es-discuss > > -- > Best regards, > Behrang Saeedzadeh > > _______________________________________________ > es-discuss mailing list > es-discuss at mozilla.org > https://mail.mozilla.org/listinfo/es-discuss >
I think poly-filling is only a good idea when the spec says a given type should have a given function but one or more browsers haven't implemented it yet.
Otherwise it will become like the era of overtly monkey patching everything in Ruby that could end up with libraries clashing with each other and leading to lots of headaches for developers.
Unless something similar to C#'s extension methods are added to EcmaScript: msdn.microsoft.com/en-AU/library/bb383977.aspx that can turned on a polyfill on a per scope basis.
I think poly-filling is only a good idea when the spec says a given type should have a given function but one or more browsers haven't implemented it yet. Otherwise it will become like the era of overtly monkey patching everything in Ruby that could end up with libraries clashing with each other and leading to lots of headaches for developers. Unless something similar to C#'s extension methods are added to EcmaScript: https://msdn.microsoft.com/en-AU/library/bb383977.aspx that can turned on a polyfill on a per scope basis. On Thu, Jul 30, 2015 at 1:12 AM Michał Wadas <michalwadas at gmail.com> wrote: > I can't remember last time when I would need `isNullOrEmpty` - > Boolean('') and Boolean(null) evaluates to false. And `if (str)` > handles any case with consistent types. > > String.isNullOrEmpty = (a)=>(typeof a === 'string' || a === null) && !a; > > Anyway - native isNullOrWhiteSpace would be probably be useful only to > reduce GC pressure, because it's easily polyfilled. > > String.isNullOrWhiteSpace = (a)=>a === null ? true : typeof a === > 'string' && !a.trim(); > > > 2015-07-29 13:27 GMT+02:00 Behrang Saeedzadeh <behrangsa at gmail.com>: > > Another set of very handy functions that in Java are provided by > libraries > > such as Guava or Apache Commons and in C# are built in, are > > `String.isNullOrEmpty(aStr)` and `String.IsNullOrWhiteSpace(aStr)`. > > > > Would be nice if they ES Strings had them too. > > > > On Tue, Jul 28, 2015 at 10:15 AM John-David Dalton > > <john.david.dalton at gmail.com> wrote: > >> > >> In the wild I've seen ltrim rtrim which are variations of trimLeft and > >> trimRight and padLeft padRight or lpad, rpad for other forms. For > stings I > >> think of left and right as leading and trailing and think of start and > end > >> as more position indicators of like slice or a range. > >> > >> > >> -JDD > >> > >> On Mon, Jul 27, 2015 at 4:55 PM, Dmitry Soshnikov > >> <dmitry.soshnikov at gmail.com> wrote: > >>> > >>> OK, it was added to the agenda for the next meeting (will be presented > by > >>> Sebastian Markbage), so can be discussed in detail. I agree that > "start", > >>> and "end" are now probably better fit (because of i18n, and a strong > >>> correlation with "startsWith" and "endsWith"). We can probably ignore > the > >>> de-facto shipped in browsers, they will just implement in addition > >>> `trimStart` and `trimEnd`, and eventually deprecate the "right" and > "left". > >>> > >>> Dmitry > >>> > >>> On Tue, Jul 21, 2015 at 12:02 AM, Claude Pache <claude.pache at gmail.com > > > >>> wrote: > >>>> > >>>> > >>>> > Le 21 juil. 2015 à 08:28, Jordan Harband <ljharb at gmail.com> a > écrit : > >>>> > > >>>> > On the contrary -"left" always begins at index 0 - "start" is > >>>> > sometimes index 0, sometimes index (length - 1). > >>>> > >>>> Counter-example: ES6 methods `String#startsWith` and `String#endsWith` > >>>> are named correctly. > >>>> > >>>> > I think "left" and "right" are the right names; "start" and "end" > >>>> > would require unicode bidirectional stuff. > >>>> > >>>> No, because characters in Unicode strings are ordered logically, not > >>>> visually. > >>>> > >>>> —Claude > >>>> > >>>> _______________________________________________ > >>>> es-discuss mailing list > >>>> es-discuss at mozilla.org > >>>> https://mail.mozilla.org/listinfo/es-discuss > >>> > >>> > >>> > >>> _______________________________________________ > >>> es-discuss mailing list > >>> es-discuss at mozilla.org > >>> https://mail.mozilla.org/listinfo/es-discuss > >>> > >> > >> _______________________________________________ > >> es-discuss mailing list > >> es-discuss at mozilla.org > >> https://mail.mozilla.org/listinfo/es-discuss > > > > -- > > Best regards, > > Behrang Saeedzadeh > > > > _______________________________________________ > > es-discuss mailing list > > es-discuss at mozilla.org > > https://mail.mozilla.org/listinfo/es-discuss > > > -- Best regards, Behrang Saeedzadeh -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150730/f45aa868/attachment-0001.html>
Closing the loop on this: this feature is now stage 4, and will be included in ES 2017. tc39/ecma262#581
Polyfills: www.npmjs.com/package/string.prototype.padstart and www.npmjs.com/package/string.prototype.padend
Closing the loop on this: this feature is now stage 4, and will be included in ES 2017. https://github.com/tc39/ecma262/pull/581 Polyfills: https://www.npmjs.com/package/string.prototype.padstart and https://www.npmjs.com/package/string.prototype.padend On Thu, Jul 30, 2015 at 10:33 AM, Behrang Saeedzadeh <behrangsa at gmail.com> wrote: > I think poly-filling is only a good idea when the spec says a given type > should have a given function but one or more browsers haven't implemented > it yet. > > Otherwise it will become like the era of overtly monkey patching > everything in Ruby that could end up with libraries clashing with each > other and leading to lots of headaches for developers. > > Unless something similar to C#'s extension methods are added to > EcmaScript: https://msdn.microsoft.com/en-AU/library/bb383977.aspx that > can turned on a polyfill on a per scope basis. > > > > On Thu, Jul 30, 2015 at 1:12 AM Michał Wadas <michalwadas at gmail.com> > wrote: > >> I can't remember last time when I would need `isNullOrEmpty` - >> Boolean('') and Boolean(null) evaluates to false. And `if (str)` >> handles any case with consistent types. >> >> String.isNullOrEmpty = (a)=>(typeof a === 'string' || a === null) && !a; >> >> Anyway - native isNullOrWhiteSpace would be probably be useful only to >> reduce GC pressure, because it's easily polyfilled. >> >> String.isNullOrWhiteSpace = (a)=>a === null ? true : typeof a === >> 'string' && !a.trim(); >> >> >> 2015-07-29 13:27 GMT+02:00 Behrang Saeedzadeh <behrangsa at gmail.com>: >> > Another set of very handy functions that in Java are provided by >> libraries >> > such as Guava or Apache Commons and in C# are built in, are >> > `String.isNullOrEmpty(aStr)` and `String.IsNullOrWhiteSpace(aStr)`. >> > >> > Would be nice if they ES Strings had them too. >> > >> > On Tue, Jul 28, 2015 at 10:15 AM John-David Dalton >> > <john.david.dalton at gmail.com> wrote: >> >> >> >> In the wild I've seen ltrim rtrim which are variations of trimLeft and >> >> trimRight and padLeft padRight or lpad, rpad for other forms. For >> stings I >> >> think of left and right as leading and trailing and think of start and >> end >> >> as more position indicators of like slice or a range. >> >> >> >> >> >> -JDD >> >> >> >> On Mon, Jul 27, 2015 at 4:55 PM, Dmitry Soshnikov >> >> <dmitry.soshnikov at gmail.com> wrote: >> >>> >> >>> OK, it was added to the agenda for the next meeting (will be >> presented by >> >>> Sebastian Markbage), so can be discussed in detail. I agree that >> "start", >> >>> and "end" are now probably better fit (because of i18n, and a strong >> >>> correlation with "startsWith" and "endsWith"). We can probably ignore >> the >> >>> de-facto shipped in browsers, they will just implement in addition >> >>> `trimStart` and `trimEnd`, and eventually deprecate the "right" and >> "left". >> >>> >> >>> Dmitry >> >>> >> >>> On Tue, Jul 21, 2015 at 12:02 AM, Claude Pache < >> claude.pache at gmail.com> >> >>> wrote: >> >>>> >> >>>> >> >>>> > Le 21 juil. 2015 à 08:28, Jordan Harband <ljharb at gmail.com> a >> écrit : >> >>>> > >> >>>> > On the contrary -"left" always begins at index 0 - "start" is >> >>>> > sometimes index 0, sometimes index (length - 1). >> >>>> >> >>>> Counter-example: ES6 methods `String#startsWith` and >> `String#endsWith` >> >>>> are named correctly. >> >>>> >> >>>> > I think "left" and "right" are the right names; "start" and "end" >> >>>> > would require unicode bidirectional stuff. >> >>>> >> >>>> No, because characters in Unicode strings are ordered logically, not >> >>>> visually. >> >>>> >> >>>> —Claude >> >>>> >> >>>> _______________________________________________ >> >>>> es-discuss mailing list >> >>>> es-discuss at mozilla.org >> >>>> https://mail.mozilla.org/listinfo/es-discuss >> >>> >> >>> >> >>> >> >>> _______________________________________________ >> >>> es-discuss mailing list >> >>> es-discuss at mozilla.org >> >>> https://mail.mozilla.org/listinfo/es-discuss >> >>> >> >> >> >> _______________________________________________ >> >> es-discuss mailing list >> >> es-discuss at mozilla.org >> >> https://mail.mozilla.org/listinfo/es-discuss >> > >> > -- >> > Best regards, >> > Behrang Saeedzadeh >> > >> > _______________________________________________ >> > es-discuss mailing list >> > es-discuss at mozilla.org >> > https://mail.mozilla.org/listinfo/es-discuss >> > >> > -- > Best regards, > Behrang Saeedzadeh > > _______________________________________________ > es-discuss mailing list > es-discuss at mozilla.org > https://mail.mozilla.org/listinfo/es-discuss > > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160525/440c512e/attachment-0001.html>
- sorry, to clarify: This was discussing padding. trimLeft/trimRight / trimStart/trimEnd is still stage 2
* sorry, to clarify: This was discussing padding. trimLeft/trimRight / trimStart/trimEnd is still stage 2 On Wed, May 25, 2016 at 2:56 PM, Jordan Harband <ljharb at gmail.com> wrote: > Closing the loop on this: this feature is now stage 4, and will be > included in ES 2017. https://github.com/tc39/ecma262/pull/581 > > Polyfills: https://www.npmjs.com/package/string.prototype.padstart and > https://www.npmjs.com/package/string.prototype.padend > > On Thu, Jul 30, 2015 at 10:33 AM, Behrang Saeedzadeh <behrangsa at gmail.com> > wrote: > >> I think poly-filling is only a good idea when the spec says a given type >> should have a given function but one or more browsers haven't implemented >> it yet. >> >> Otherwise it will become like the era of overtly monkey patching >> everything in Ruby that could end up with libraries clashing with each >> other and leading to lots of headaches for developers. >> >> Unless something similar to C#'s extension methods are added to >> EcmaScript: https://msdn.microsoft.com/en-AU/library/bb383977.aspx that >> can turned on a polyfill on a per scope basis. >> >> >> >> On Thu, Jul 30, 2015 at 1:12 AM Michał Wadas <michalwadas at gmail.com> >> wrote: >> >>> I can't remember last time when I would need `isNullOrEmpty` - >>> Boolean('') and Boolean(null) evaluates to false. And `if (str)` >>> handles any case with consistent types. >>> >>> String.isNullOrEmpty = (a)=>(typeof a === 'string' || a === null) && !a; >>> >>> Anyway - native isNullOrWhiteSpace would be probably be useful only to >>> reduce GC pressure, because it's easily polyfilled. >>> >>> String.isNullOrWhiteSpace = (a)=>a === null ? true : typeof a === >>> 'string' && !a.trim(); >>> >>> >>> 2015-07-29 13:27 GMT+02:00 Behrang Saeedzadeh <behrangsa at gmail.com>: >>> > Another set of very handy functions that in Java are provided by >>> libraries >>> > such as Guava or Apache Commons and in C# are built in, are >>> > `String.isNullOrEmpty(aStr)` and `String.IsNullOrWhiteSpace(aStr)`. >>> > >>> > Would be nice if they ES Strings had them too. >>> > >>> > On Tue, Jul 28, 2015 at 10:15 AM John-David Dalton >>> > <john.david.dalton at gmail.com> wrote: >>> >> >>> >> In the wild I've seen ltrim rtrim which are variations of trimLeft and >>> >> trimRight and padLeft padRight or lpad, rpad for other forms. For >>> stings I >>> >> think of left and right as leading and trailing and think of start >>> and end >>> >> as more position indicators of like slice or a range. >>> >> >>> >> >>> >> -JDD >>> >> >>> >> On Mon, Jul 27, 2015 at 4:55 PM, Dmitry Soshnikov >>> >> <dmitry.soshnikov at gmail.com> wrote: >>> >>> >>> >>> OK, it was added to the agenda for the next meeting (will be >>> presented by >>> >>> Sebastian Markbage), so can be discussed in detail. I agree that >>> "start", >>> >>> and "end" are now probably better fit (because of i18n, and a strong >>> >>> correlation with "startsWith" and "endsWith"). We can probably >>> ignore the >>> >>> de-facto shipped in browsers, they will just implement in addition >>> >>> `trimStart` and `trimEnd`, and eventually deprecate the "right" and >>> "left". >>> >>> >>> >>> Dmitry >>> >>> >>> >>> On Tue, Jul 21, 2015 at 12:02 AM, Claude Pache < >>> claude.pache at gmail.com> >>> >>> wrote: >>> >>>> >>> >>>> >>> >>>> > Le 21 juil. 2015 à 08:28, Jordan Harband <ljharb at gmail.com> a >>> écrit : >>> >>>> > >>> >>>> > On the contrary -"left" always begins at index 0 - "start" is >>> >>>> > sometimes index 0, sometimes index (length - 1). >>> >>>> >>> >>>> Counter-example: ES6 methods `String#startsWith` and >>> `String#endsWith` >>> >>>> are named correctly. >>> >>>> >>> >>>> > I think "left" and "right" are the right names; "start" and "end" >>> >>>> > would require unicode bidirectional stuff. >>> >>>> >>> >>>> No, because characters in Unicode strings are ordered logically, not >>> >>>> visually. >>> >>>> >>> >>>> —Claude >>> >>>> >>> >>>> _______________________________________________ >>> >>>> es-discuss mailing list >>> >>>> es-discuss at mozilla.org >>> >>>> https://mail.mozilla.org/listinfo/es-discuss >>> >>> >>> >>> >>> >>> >>> >>> _______________________________________________ >>> >>> es-discuss mailing list >>> >>> es-discuss at mozilla.org >>> >>> https://mail.mozilla.org/listinfo/es-discuss >>> >>> >>> >> >>> >> _______________________________________________ >>> >> es-discuss mailing list >>> >> es-discuss at mozilla.org >>> >> https://mail.mozilla.org/listinfo/es-discuss >>> > >>> > -- >>> > Best regards, >>> > Behrang Saeedzadeh >>> > >>> > _______________________________________________ >>> > es-discuss mailing list >>> > es-discuss at mozilla.org >>> > https://mail.mozilla.org/listinfo/es-discuss >>> > >>> >> -- >> Best regards, >> Behrang Saeedzadeh >> >> _______________________________________________ >> es-discuss mailing list >> es-discuss at mozilla.org >> https://mail.mozilla.org/listinfo/es-discuss >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160525/9890d263/attachment.html>
Just got a question why don't we polyfill
trimLeft
andtrimRight
for strings, and have onlytrim
(and the answer is -- because it's not part of ES5/ES6).Just thinking could it be a valid cases when a dev may want to trim only form right still keeping e.g. the precalculated padding on the left (seems legit)?
MDN mentions them [1], [2], though as non-standard. What stopping both methods to be included?
[1] developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trimLeft [2] developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/TrimRight
Dmitry