archives

« Bugzilla Issues Index

#2561 — Array.from usingIterator path: mapfn call is missing args


The call to mapfn is missing two arguments.

Expect:
kValue, k, items

Actual:
kValue


The arrayLike path is correct


It isn't clear to me that three arguments are correct for the iterator case.

The three arguments derive from A.p.map where direct indexing is used rather than an iterator. The second argument is an index into the third argument. Presumably, the intent is that the callback function could use the 2nd and 3rd argument to probe around in the collection being iterated.

But when an iterator is being used instead of a collection, it isn't clear that there is anything useful that the callback function could do if it was passed the iterator. Similarly, we don't have a an index associated with the iterator, just an iteration count that can't be used to access into the iterator.

I seems to me that passing only one argument, is still best. That way will somebody does pass in a callback that expects three arguments they will probably get an exception when they try to index into non-existent the 3rd argument.

If you feel strongly otherwise you might want to discuss this on esdiscuss


fixed in rev24 editor's draft

updated as per TC39 meeting consensus https://github.com/rwaldron/tc39-notes/blob/master/es6/2014-04/apr-9.md#signature-of-arrayfrom-map-callback


fixed in rev24