Feature proposal
Mike Samuel
mikesamuel at gmail.com
Wed Jul 18 18:43:51 UTC 2018
On Wed, Jul 18, 2018 at 2:06 PM Nicolas B. Pierron <
nicolas.b.pierron at mozilla.com> wrote:
> On Wed, Jul 18, 2018 at 5:31 PM, Michael Luder-Rosefield
> <rosyatrandom at gmail.com> wrote:
> > At the moment, we have:
> >
> > every
> > filter
> > find
> > findIndex
> > forEach
> > indexOf / lastIndexOf
> > map
> > reduce / reduceRight
> > some
> >
> > which is not very consistent at all. Perhaps we could add an `iterOrder`
> > method that changes the way the array is iterated through?
>
> Stupid question, but why are some of these methods implemented on
> String, Array, TypedArray, Map and Set, while all of them are
> Iteratable?
>
String is different from the others.
The String index methods deal with a contiguous subsequence of the
sequence, not the index of an element in the sequence.
> If we were to add all these methods on Iteratable, then one could add
> a `reverse` generator property on Iteratable.
>
Reverse is problematic on String. The index of a codepoint can't be
subtracted from String.length since length is not the count of codepoints.
> Iteratable.prototype.reverse = function* reverse() { … };
> foo.reverse().forEach( e => console.log(e) )
>
> Though, this implies that all these objects implement the Iteratable
> prototype, and I am not sure what impact this might have on the Web.
>
--
> Nicolas B. Pierron
> _______________________________________________
> 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/20180718/a7024c6c/attachment.html>
More information about the es-discuss
mailing list