Update Array.from callback signature

It's up to latest TC39 consensus:
https://github.com/rwaldron/tc39-notes/blob/master/es6/2014-04/apr-9.md#conclusionresolution-4
This commit is contained in:
Mariusz Nowak
2014-04-16 15:08:04 +02:00
parent 0a506bf515
commit 81d5ea562f
+4 -2
View File
@@ -23,8 +23,10 @@ module.exports = function (arrayLike/*, mapFn, thisArg*/) {
result = iterator.next();
i = 0;
while (!result.done) {
arr[i++] = mapFn ? call.call(mapFn, thisArg, result.value) : result.value;
arr[i] = mapFn ? call.call(mapFn, thisArg, result.value, i)
: result.value;
result = iterator.next();
++i;
}
return arr;
}
@@ -32,7 +34,7 @@ module.exports = function (arrayLike/*, mapFn, thisArg*/) {
l = toPosInt(arrayLike.length);
if (mapFn != null) {
arr = new Constructor(l);
for (i = 0; i < l; ++i) arr[i] = call.call(mapFn, thisArg, arrayLike[i]);
for (i = 0; i < l; ++i) arr[i] = call.call(mapFn, thisArg, arrayLike[i], i);
return arr;
}