mirror of
https://github.com/hanzoai/es5-ext.git
synced 2026-09-24 16:58:43 +00:00
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:
+4
-2
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user