On Wed, Jul 18, 2018 at 2:06 PM Nicolas B. Pierron < [email protected]> wrote:
> On Wed, Jul 18, 2018 at 5:31 PM, Michael Luder-Rosefield > <[email protected]> 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 > [email protected] > https://mail.mozilla.org/listinfo/es-discuss >
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

