|
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:
755 bytes
|
| Line | |
|---|
| 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 |
|
|---|
| 10 | var isObject = require('es-object-atoms/isObject');
|
|---|
| 11 |
|
|---|
| 12 | var ES = {
|
|---|
| 13 | AdvanceStringIndex: AdvanceStringIndex,
|
|---|
| 14 | GetMethod: GetMethod
|
|---|
| 15 | };
|
|---|
| 16 |
|
|---|
| 17 | // https://262.ecma-international.org/6.0/#sec-getiterator
|
|---|
| 18 |
|
|---|
| 19 | module.exports = function GetIterator(obj, method) {
|
|---|
| 20 | var actualMethod = method;
|
|---|
| 21 | if (arguments.length < 2) {
|
|---|
| 22 | actualMethod = getIteratorMethod(ES, obj);
|
|---|
| 23 | }
|
|---|
| 24 | var iterator = Call(actualMethod, obj);
|
|---|
| 25 | if (!isObject(iterator)) {
|
|---|
| 26 | throw new $TypeError('iterator must return an object');
|
|---|
| 27 | }
|
|---|
| 28 |
|
|---|
| 29 | return iterator;
|
|---|
| 30 | };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.