2 var fails = require('../internals/fails');
3 var isCallable = require('../internals/is-callable');
4 var create = require('../internals/object-create');
5 var getPrototypeOf = require('../internals/object-get-prototype-of');
6 var redefine = require('../internals/redefine');
7 var wellKnownSymbol = require('../internals/well-known-symbol');
8 var IS_PURE = require('../internals/is-pure');
10 var ITERATOR = wellKnownSymbol('iterator');
11 var BUGGY_SAFARI_ITERATORS = false;
13 // `%IteratorPrototype%` object
14 // https://tc39.es/ecma262/#sec-%iteratorprototype%-object
15 var IteratorPrototype, PrototypeOfArrayIteratorPrototype, arrayIterator;
17 /* eslint-disable es/no-array-prototype-keys -- safe */
19 arrayIterator = [].keys();
20 // Safari 8 has buggy iterators w/o `next`
21 if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS = true;
23 PrototypeOfArrayIteratorPrototype = getPrototypeOf(getPrototypeOf(arrayIterator));
24 if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype = PrototypeOfArrayIteratorPrototype;
28 var NEW_ITERATOR_PROTOTYPE = IteratorPrototype == undefined || fails(function () {
30 // FF44- legacy iterators case
31 return IteratorPrototype[ITERATOR].call(test) !== test;
34 if (NEW_ITERATOR_PROTOTYPE) IteratorPrototype = {};
35 else if (IS_PURE) IteratorPrototype = create(IteratorPrototype);
37 // `%IteratorPrototype%[@@iterator]()` method
38 // https://tc39.es/ecma262/#sec-%iteratorprototype%-@@iterator
39 if (!isCallable(IteratorPrototype[ITERATOR])) {
40 redefine(IteratorPrototype, ITERATOR, function () {
46 IteratorPrototype: IteratorPrototype,
47 BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS