Skip to content

Commit 2417a1d

Browse files
committed
fix order of arguments validation in Array.fromAsync polyfill
1 parent 69208f8 commit 2417a1d

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
- Fixed double `.return()` calling in case of throwing error in this method in the internal `iterate` helper that affected some polyfills
1616
- Fixed closing iterator on `IteratorValue` errors in the internal `iterate` helper that affected some polyfills
1717
- Fixed iterator closing in `Array.from` polyfill on failure to create array property
18+
- Fixed order of arguments validation in `Array.fromAsync` polyfill
1819
- Fixed order of arguments validation in `Array.prototype.flat` polyfill
1920
- Fixed handling strings as iterables in `Iterator.{ zip, zipKeyed }` polyfills
2021
- Fixed some cases of iterators closing in `Iterator.{ zip, zipKeyed }` polyfills

packages/core-js/internals/array-from-async.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use strict';
22
var bind = require('../internals/function-bind-context');
33
var uncurryThis = require('../internals/function-uncurry-this');
4-
var toObject = require('../internals/to-object');
54
var isConstructor = require('../internals/is-constructor');
65
var getAsyncIterator = require('../internals/get-async-iterator');
76
var getIterator = require('../internals/get-iterator');
@@ -32,20 +31,19 @@ SafeArrayIterator.prototype.next = function () {
3231

3332
// `Array.fromAsync` method implementation
3433
// https://github.com/tc39/proposal-array-from-async
35-
module.exports = function fromAsync(asyncItems /* , mapfn = undefined, thisArg = undefined */) {
34+
module.exports = function fromAsync(items /* , mapfn = undefined, thisArg = undefined */) {
3635
var C = this;
3736
var argumentsLength = arguments.length;
3837
var mapfn = argumentsLength > 1 ? arguments[1] : undefined;
3938
var thisArg = argumentsLength > 2 ? arguments[2] : undefined;
4039
return new (getBuiltIn('Promise'))(function (resolve) {
41-
var O = toObject(asyncItems);
4240
if (mapfn !== undefined) mapfn = bind(mapfn, thisArg);
43-
var usingAsyncIterator = getMethod(O, ASYNC_ITERATOR);
44-
var usingSyncIterator = usingAsyncIterator ? undefined : getIteratorMethod(O) || safeArrayIterator;
41+
var usingAsyncIterator = getMethod(items, ASYNC_ITERATOR);
42+
var usingSyncIterator = usingAsyncIterator ? undefined : getIteratorMethod(items) || safeArrayIterator;
4543
var A = isConstructor(C) ? new C() : [];
4644
var iterator = usingAsyncIterator
47-
? getAsyncIterator(O, usingAsyncIterator)
48-
: new AsyncFromSyncIterator(getIteratorDirect(getIterator(O, usingSyncIterator)));
45+
? getAsyncIterator(items, usingAsyncIterator)
46+
: new AsyncFromSyncIterator(getIteratorDirect(getIterator(items, usingSyncIterator)));
4947
resolve(toArray(iterator, mapfn, A));
5048
});
5149
};

0 commit comments

Comments
 (0)