main
Last change
on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
805 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');
|
---|
[79a0317] | 10 |
|
---|
| 11 | var isObject = require('../helpers/isObject');
|
---|
| 12 |
|
---|
| 13 | var ES = {
|
---|
| 14 | AdvanceStringIndex: AdvanceStringIndex,
|
---|
| 15 | GetMethod: GetMethod,
|
---|
| 16 | IsArray: IsArray
|
---|
| 17 | };
|
---|
[d565449] | 18 |
|
---|
| 19 | // https://262.ecma-international.org/6.0/#sec-getiterator
|
---|
| 20 |
|
---|
| 21 | module.exports = function GetIterator(obj, method) {
|
---|
| 22 | var actualMethod = method;
|
---|
| 23 | if (arguments.length < 2) {
|
---|
[79a0317] | 24 | actualMethod = getIteratorMethod(ES, obj);
|
---|
[d565449] | 25 | }
|
---|
| 26 | var iterator = Call(actualMethod, obj);
|
---|
[79a0317] | 27 | if (!isObject(iterator)) {
|
---|
[d565449] | 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.