main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
803 bytes
|
Rev | Line | |
---|
[d565449] | 1 | 'use strict';
|
---|
| 2 |
|
---|
| 3 | var $TypeError = require('es-errors/type');
|
---|
| 4 |
|
---|
| 5 | var getIteratorMethod = require('../helpers/getIteratorMethod');
|
---|
| 6 | var AdvanceStringIndex = require('./AdvanceStringIndex');
|
---|
| 7 | var Call = require('./Call');
|
---|
| 8 | var GetMethod = require('./GetMethod');
|
---|
| 9 | var IsArray = require('./IsArray');
|
---|
| 10 | var Type = require('./Type');
|
---|
| 11 |
|
---|
| 12 | // https://262.ecma-international.org/6.0/#sec-getiterator
|
---|
| 13 |
|
---|
| 14 | module.exports = function GetIterator(obj, method) {
|
---|
| 15 | var actualMethod = method;
|
---|
| 16 | if (arguments.length < 2) {
|
---|
| 17 | actualMethod = getIteratorMethod(
|
---|
| 18 | {
|
---|
| 19 | AdvanceStringIndex: AdvanceStringIndex,
|
---|
| 20 | GetMethod: GetMethod,
|
---|
| 21 | IsArray: IsArray
|
---|
| 22 | },
|
---|
| 23 | obj
|
---|
| 24 | );
|
---|
| 25 | }
|
---|
| 26 | var iterator = Call(actualMethod, obj);
|
---|
| 27 | if (Type(iterator) !== 'Object') {
|
---|
| 28 | throw new $TypeError('iterator must return an object');
|
---|
| 29 | }
|
---|
| 30 |
|
---|
| 31 | return iterator;
|
---|
| 32 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.