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
|
Rev | Line | |
---|
[d565449] | 1 | 'use strict';
|
---|
| 2 |
|
---|
| 3 | var $TypeError = require('es-errors/type');
|
---|
| 4 |
|
---|
| 5 | var GetIteratorFlattenable = require('../aos/GetIteratorFlattenable');
|
---|
| 6 | var OrdinaryHasInstance = require('es-abstract/2024/OrdinaryHasInstance');
|
---|
| 7 | var OrdinaryObjectCreate = require('es-abstract/2024/OrdinaryObjectCreate');
|
---|
| 8 |
|
---|
| 9 | var $Iterator = require('../Iterator/polyfill')();
|
---|
| 10 | var $WrapForValidIteratorPrototype = require('../WrapForValidIteratorPrototype');
|
---|
| 11 |
|
---|
| 12 | var SLOT = require('internal-slot');
|
---|
| 13 |
|
---|
| 14 | module.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.