source: imaps-frontend/node_modules/es-abstract/2023/GetIteratorFromMethod.js@ 79a0317

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: 737 bytes
Line 
1'use strict';
2
3var $TypeError = require('es-errors/type');
4
5var Call = require('./Call');
6var GetV = require('./GetV');
7var IsCallable = require('./IsCallable');
8
9var isObject = require('../helpers/isObject');
10
11// https://262.ecma-international.org/14.0/#sec-getiteratorfrommethod
12
13module.exports = function GetIteratorFromMethod(obj, method) {
14 if (!IsCallable(method)) {
15 throw new $TypeError('method must be a function');
16 }
17
18 var iterator = Call(method, obj); // step 1
19 if (!isObject(iterator)) {
20 throw new $TypeError('iterator must return an object'); // step 2
21 }
22
23 var nextMethod = GetV(iterator, 'next'); // step 3
24 return { // steps 4-5
25 '[[Iterator]]': iterator,
26 '[[NextMethod]]': nextMethod,
27 '[[Done]]': false
28 };
29};
Note: See TracBrowser for help on using the repository browser.