source: imaps-frontend/node_modules/es-abstract/2024/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: 734 bytes
RevLine 
[d565449]1'use strict';
2
3var $TypeError = require('es-errors/type');
4
5var Call = require('./Call');
6var Get = require('./Get');
7var IsCallable = require('./IsCallable');
[79a0317]8
9var isObject = require('../helpers/isObject');
[d565449]10
11// https://262.ecma-international.org/15.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
[79a0317]19 if (!isObject(iterator)) {
[d565449]20 throw new $TypeError('iterator must return an object'); // step 2
21 }
22
23 var nextMethod = Get(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.