source: imaps-frontend/node_modules/es-iterator-helpers/Iterator.from/implementation.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.0 KB
RevLine 
[d565449]1'use strict';
2
3var $TypeError = require('es-errors/type');
4
5var GetIteratorFlattenable = require('../aos/GetIteratorFlattenable');
6var OrdinaryHasInstance = require('es-abstract/2024/OrdinaryHasInstance');
7var OrdinaryObjectCreate = require('es-abstract/2024/OrdinaryObjectCreate');
8
9var $Iterator = require('../Iterator/polyfill')();
10var $WrapForValidIteratorPrototype = require('../WrapForValidIteratorPrototype');
11
12var SLOT = require('internal-slot');
13
14module.exports = function from(O) {
15 if (this instanceof from) {
16 throw new $TypeError('`Iterator.from` is not a constructor');
17 }
18
19 var iteratorRecord = GetIteratorFlattenable(O, 'iterate-strings'); // step 1
20
21 var hasInstance = OrdinaryHasInstance($Iterator, iteratorRecord['[[Iterator]]']); // step 2
22
23 if (hasInstance) { // step 3
24 return iteratorRecord['[[Iterator]]']; // step 3.a
25 }
26
27 var wrapper = OrdinaryObjectCreate($WrapForValidIteratorPrototype); // , ['[[Iterated]]']); // step 4
28
29 SLOT.set(wrapper, '[[Iterated]]', iteratorRecord); // step 5
30
31 return wrapper; // step 6
32};
Note: See TracBrowser for help on using the repository browser.