String.prototype.padLeft / String.prototype.padRight
Coroutines
coroutines at gmail.com
Tue Nov 17 21:29:38 UTC 2015
On Tue, Nov 17, 2015 at 1:13 PM, Jeremy Darling
<jeremy.darling at gmail.com> wrote:
> Just as an aside, I think padLeft/padRight should still be added in addition
> to padStart/padEnd. There are times (token generation, identity padding,
> etc) where you would want to specify the handedness of the pad operation and
> ignore the locale. This goes for the trim* methods as well.
I disagree with what has been decided. :p
I was in favor of {trim,pad}{Right,Left}(). The reason: Iterators.
As JS moves forward toward people creating iterators to traverse an
object, referring to the start and end of something *can* be
ambiguous. There is no confusion with *Left() or *Right().
I had assumed Start/End were chosen because it would be another move
to avoid very generic names. Like how we have Array::some() instead
of Array::any(), and Array::every() instead of Array::all().
Less-generic names allows people to monkey-patch without obvious
collisions. I am a fan of adding to String instead of making my own
XString.
More information about the es-discuss
mailing list