diff --git a/CHANGELOG.md b/CHANGELOG.md index 30e5c6260df1..ce85c2a3432c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ - Added a workaround for iOS Safari MessageChannel + bfcache bug, [#624](https://github.com/zloirock/core-js/issues/624) - Added compat data for Node 12.9, FF 69 and Phantom 1.9 - Fixed unnecessary exposing on `Symbol.matchAll` in `esnext.string.match-all`, [#626](https://github.com/zloirock/core-js/issues/626) +- Fixed missed cases [access the `.next` method once, at the beginning, of the iteration protocol](https://github.com/tc39/ecma262/issues/976) - Show similar `postinstall` messages only once per `npm i`, [#597](https://github.com/zloirock/core-js/issues/597), thanks [@remy](https://github.com/remy) ##### 3.2.1 - 2019.08.12 diff --git a/packages/core-js/internals/array-from.js b/packages/core-js/internals/array-from.js index 9a689463a0a6..e45ebe493c0b 100644 --- a/packages/core-js/internals/array-from.js +++ b/packages/core-js/internals/array-from.js @@ -17,13 +17,14 @@ module.exports = function from(arrayLike /* , mapfn = undefined, thisArg = undef var mapping = mapfn !== undefined; var index = 0; var iteratorMethod = getIteratorMethod(O); - var length, result, step, iterator; + var length, result, step, iterator, next; if (mapping) mapfn = bind(mapfn, argumentsLength > 2 ? arguments[2] : undefined, 2); // if the target is not iterable or it's an array with the default iterator - use a simple case if (iteratorMethod != undefined && !(C == Array && isArrayIteratorMethod(iteratorMethod))) { iterator = iteratorMethod.call(O); + next = iterator.next; result = new C(); - for (;!(step = iterator.next()).done; index++) { + for (;!(step = next.call(iterator)).done; index++) { createProperty(result, index, mapping ? callWithSafeIterationClosing(iterator, mapfn, [step.value, index], true) : step.value diff --git a/packages/core-js/internals/typed-array-from.js b/packages/core-js/internals/typed-array-from.js index 28d6e3456e13..8a4debdf54f0 100644 --- a/packages/core-js/internals/typed-array-from.js +++ b/packages/core-js/internals/typed-array-from.js @@ -11,11 +11,12 @@ module.exports = function from(source /* , mapfn, thisArg */) { var mapfn = argumentsLength > 1 ? arguments[1] : undefined; var mapping = mapfn !== undefined; var iteratorMethod = getIteratorMethod(O); - var i, length, result, step, iterator; + var i, length, result, step, iterator, next; if (iteratorMethod != undefined && !isArrayIteratorMethod(iteratorMethod)) { iterator = iteratorMethod.call(O); + next = iterator.next; O = []; - while (!(step = iterator.next()).done) { + while (!(step = next.call(iterator)).done) { O.push(step.value); } } diff --git a/packages/core-js/modules/web.url-search-params.js b/packages/core-js/modules/web.url-search-params.js index 57454b3276a9..7d046ba04b65 100644 --- a/packages/core-js/modules/web.url-search-params.js +++ b/packages/core-js/modules/web.url-search-params.js @@ -121,7 +121,7 @@ var URLSearchParamsConstructor = function URLSearchParams(/* init */) { var init = arguments.length > 0 ? arguments[0] : undefined; var that = this; var entries = []; - var iteratorMethod, iterator, step, entryIterator, first, second, key; + var iteratorMethod, iterator, next, step, entryIterator, entryNext, first, second, key; setInternalState(that, { type: URL_SEARCH_PARAMS, @@ -135,12 +135,14 @@ var URLSearchParamsConstructor = function URLSearchParams(/* init */) { iteratorMethod = getIteratorMethod(init); if (typeof iteratorMethod === 'function') { iterator = iteratorMethod.call(init); - while (!(step = iterator.next()).done) { + next = iterator.next; + while (!(step = next.call(iterator)).done) { entryIterator = getIterator(anObject(step.value)); + entryNext = entryIterator.next; if ( - (first = entryIterator.next()).done || - (second = entryIterator.next()).done || - !entryIterator.next().done + (first = entryNext.call(entryIterator)).done || + (second = entryNext.call(entryIterator)).done || + !entryNext.call(entryIterator).done ) throw TypeError('Expected sequence with length 2'); entries.push({ key: first.value + '', value: second.value + '' }); }