From 21cb9828fb314099510f4904a0ea2a10679c3c9b Mon Sep 17 00:00:00 2001 From: Denis Pushkarev Date: Fri, 7 Jul 2023 05:15:38 +0700 Subject: [PATCH] fix `AsyncIteratorPrototype` option in the configurator, close #1268 --- README.md | 11 +++++++++++ packages/core-js/configurator.js | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c1e22e3cdd0f..f473df89576b 100644 --- a/README.md +++ b/README.md @@ -2491,6 +2491,17 @@ configurator({ USE_FUNCTION_CONSTRUCTOR: true }); require('core-js/actual/async-iterator'); +(async function * () { /* empty */ })() instanceof AsyncIterator; // => true +``` +- As an alternative, you could pass to the `core-js/configurator` an object that will be considered as `%AsyncIteratorPrototype%`: +```js +const configurator = require('core-js/configurator'); +const { getPrototypeOf } = Object; + +configurator({ AsyncIteratorPrototype: getPrototypeOf(getPrototypeOf(getPrototypeOf(async function * () { /* empty */ }()))) }); + +require('core-js/actual/async-iterator'); + (async function * () { /* empty */ })() instanceof AsyncIterator; // => true ``` ##### [`Iterator.range`](https://github.com/tc39/proposal-Number.range)[⬆](#index) diff --git a/packages/core-js/configurator.js b/packages/core-js/configurator.js index 57e019dd9b3b..a556cc5ae28e 100644 --- a/packages/core-js/configurator.js +++ b/packages/core-js/configurator.js @@ -21,7 +21,7 @@ module.exports = function (options) { shared[USE_FUNCTION_CONSTRUCTOR] = !!options[USE_FUNCTION_CONSTRUCTOR]; } if (hasOwn(options, ASYNC_ITERATOR_PROTOTYPE)) { - shared[USE_FUNCTION_CONSTRUCTOR] = options[ASYNC_ITERATOR_PROTOTYPE]; + shared[ASYNC_ITERATOR_PROTOTYPE] = options[ASYNC_ITERATOR_PROTOTYPE]; } } };