1 | 'use strict';
|
2 | var fails = require('../internals/fails');
|
3 | var isCallable = require('../internals/is-callable');
|
4 | var isObject = require('../internals/is-object');
|
5 | var create = require('../internals/object-create');
|
6 | var getPrototypeOf = require('../internals/object-get-prototype-of');
|
7 | var defineBuiltIn = require('../internals/define-built-in');
|
8 | var wellKnownSymbol = require('../internals/well-known-symbol');
|
9 | var IS_PURE = require('../internals/is-pure');
|
10 |
|
11 | var ITERATOR = wellKnownSymbol('iterator');
|
12 | var BUGGY_SAFARI_ITERATORS = false;
|
13 |
|
14 |
|
15 |
|
16 | var IteratorPrototype, PrototypeOfArrayIteratorPrototype, arrayIterator;
|
17 |
|
18 |
|
19 | if ([].keys) {
|
20 | arrayIterator = [].keys();
|
21 |
|
22 | if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS = true;
|
23 | else {
|
24 | PrototypeOfArrayIteratorPrototype = getPrototypeOf(getPrototypeOf(arrayIterator));
|
25 | if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype = PrototypeOfArrayIteratorPrototype;
|
26 | }
|
27 | }
|
28 |
|
29 | var NEW_ITERATOR_PROTOTYPE = !isObject(IteratorPrototype) || fails(function () {
|
30 | var test = {};
|
31 |
|
32 | return IteratorPrototype[ITERATOR].call(test) !== test;
|
33 | });
|
34 |
|
35 | if (NEW_ITERATOR_PROTOTYPE) IteratorPrototype = {};
|
36 | else if (IS_PURE) IteratorPrototype = create(IteratorPrototype);
|
37 |
|
38 |
|
39 |
|
40 | if (!isCallable(IteratorPrototype[ITERATOR])) {
|
41 | defineBuiltIn(IteratorPrototype, ITERATOR, function () {
|
42 | return this;
|
43 | });
|
44 | }
|
45 |
|
46 | module.exports = {
|
47 | IteratorPrototype: IteratorPrototype,
|
48 | BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS
|
49 | };
|