source: imaps-frontend/node_modules/es-abstract/2019/GetIterator.js@ d565449

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
Line 
1'use strict';
2
3var $TypeError = require('es-errors/type');
4
5var getIteratorMethod = require('../helpers/getIteratorMethod');
6var AdvanceStringIndex = require('./AdvanceStringIndex');
7var Call = require('./Call');
8var GetMethod = require('./GetMethod');
9var IsArray = require('./IsArray');
10var Type = require('./Type');
11
12// https://262.ecma-international.org/6.0/#sec-getiterator
13
14module.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.