Last change
on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
978 bytes
|
Line | |
---|
1 | var wellKnownSymbol = require('../internals/well-known-symbol');
|
---|
2 |
|
---|
3 | var ITERATOR = wellKnownSymbol('iterator');
|
---|
4 | var SAFE_CLOSING = false;
|
---|
5 |
|
---|
6 | try {
|
---|
7 | var called = 0;
|
---|
8 | var iteratorWithReturn = {
|
---|
9 | next: function () {
|
---|
10 | return { done: !!called++ };
|
---|
11 | },
|
---|
12 | 'return': function () {
|
---|
13 | SAFE_CLOSING = true;
|
---|
14 | }
|
---|
15 | };
|
---|
16 | iteratorWithReturn[ITERATOR] = function () {
|
---|
17 | return this;
|
---|
18 | };
|
---|
19 | // eslint-disable-next-line es/no-array-from, no-throw-literal -- required for testing
|
---|
20 | Array.from(iteratorWithReturn, function () { throw 2; });
|
---|
21 | } catch (error) { /* empty */ }
|
---|
22 |
|
---|
23 | module.exports = function (exec, SKIP_CLOSING) {
|
---|
24 | if (!SKIP_CLOSING && !SAFE_CLOSING) return false;
|
---|
25 | var ITERATION_SUPPORT = false;
|
---|
26 | try {
|
---|
27 | var object = {};
|
---|
28 | object[ITERATOR] = function () {
|
---|
29 | return {
|
---|
30 | next: function () {
|
---|
31 | return { done: ITERATION_SUPPORT = true };
|
---|
32 | }
|
---|
33 | };
|
---|
34 | };
|
---|
35 | exec(object);
|
---|
36 | } catch (error) { /* empty */ }
|
---|
37 | return ITERATION_SUPPORT;
|
---|
38 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.