Skip to content

Commit

Permalink
prevent double get of @@(async)iterator property
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Aug 28, 2021
1 parent 9773ec3 commit 5bb48b3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions packages/core-js/internals/get-async-iterator.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ var wellKnownSymbol = require('../internals/well-known-symbol');

var ASYNC_ITERATOR = wellKnownSymbol('asyncIterator');

module.exports = function (it) {
var method = getMethod(it[ASYNC_ITERATOR]);
module.exports = function (it, usingIterator) {
var method = arguments.length < 2 ? getMethod(it[ASYNC_ITERATOR]) : usingIterator;
if (method === undefined) {
return new AsyncFromSyncIterator(getIterator(it));
} return anObject(aFunction(method).call(it));
Expand Down
4 changes: 2 additions & 2 deletions packages/core-js/internals/get-iterator.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
var anObject = require('../internals/an-object');
var getIteratorMethod = require('../internals/get-iterator-method');

module.exports = function (it) {
var iteratorMethod = getIteratorMethod(it);
module.exports = function (it, usingIterator) {
var iteratorMethod = arguments.length < 2 ? getIteratorMethod(it) : usingIterator;
if (typeof iteratorMethod != 'function') {
throw TypeError(String(it) + ' is not iterable');
} return anObject(iteratorMethod.call(it));
Expand Down
6 changes: 3 additions & 3 deletions packages/core-js/modules/esnext.async-iterator.from.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// https://github.com/tc39/proposal-iterator-helpers
var $ = require('../internals/export');
var path = require('../internals/path');
var aFunction = require('../internals/a-function');
var anObject = require('../internals/an-object');
var toObject = require('../internals/to-object');
var createAsyncIteratorProxy = require('../internals/async-iterator-create-proxy');
var getAsyncIterator = require('../internals/get-async-iterator');
var getIterator = require('../internals/get-iterator');
var getIteratorMethod = require('../internals/get-iterator-method');
var getMethod = require('../internals/get-method');
var wellKnownSymbol = require('../internals/well-known-symbol');
Expand All @@ -25,12 +25,12 @@ $({ target: 'AsyncIterator', stat: true }, {
var usingIterator = getMethod(object[ASYNC_ITERATOR]);
var iterator;
if (usingIterator !== undefined) {
iterator = getAsyncIterator(object);
iterator = getAsyncIterator(object, usingIterator);
if (iterator instanceof AsyncIterator) return iterator;
}
if (iterator === undefined) {
usingIterator = getIteratorMethod(object);
if (usingIterator !== undefined) return new AsyncFromSyncIterator(aFunction(usingIterator).call(object));
if (usingIterator !== undefined) return new AsyncFromSyncIterator(getIterator(object, usingIterator));
}
return new AsyncIteratorProxy({
iterator: iterator !== undefined ? iterator : object
Expand Down

0 comments on commit 5bb48b3

Please sign in to comment.