source: frontend/node_modules/core-js-pure/modules/es.iterator.from.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1.3 KB
Line 
1'use strict';
2var $ = require('../internals/export');
3var call = require('../internals/function-call');
4var toObject = require('../internals/to-object');
5var isPrototypeOf = require('../internals/object-is-prototype-of');
6var IteratorPrototype = require('../internals/iterators-core').IteratorPrototype;
7var createIteratorProxy = require('../internals/iterator-create-proxy');
8var getIteratorFlattenable = require('../internals/get-iterator-flattenable');
9var IS_PURE = require('../internals/is-pure');
10
11var FORCED = IS_PURE || function () {
12 // Should not throw when an underlying iterator's `return` method is null
13 // https://bugs.webkit.org/show_bug.cgi?id=288714
14 try {
15 // eslint-disable-next-line es/no-iterator -- required for testing
16 Iterator.from({ 'return': null })['return']();
17 } catch (error) {
18 return true;
19 }
20}();
21
22var IteratorProxy = createIteratorProxy(function () {
23 return call(this.next, this.iterator);
24}, true);
25
26// `Iterator.from` method
27// https://tc39.es/ecma262/#sec-iterator.from
28$({ target: 'Iterator', stat: true, forced: FORCED }, {
29 from: function from(O) {
30 var iteratorRecord = getIteratorFlattenable(typeof O == 'string' ? toObject(O) : O, true);
31 return isPrototypeOf(IteratorPrototype, iteratorRecord.iterator)
32 ? iteratorRecord.iterator
33 : new IteratorProxy(iteratorRecord);
34 }
35});
Note: See TracBrowser for help on using the repository browser.