12345678910111213141516171819202122232425262728 |
- 'use strict';
- var $TypeError = require('es-errors/type');
- var Call = require('./Call');
- var GetV = require('./GetV');
- var IsCallable = require('./IsCallable');
- var Type = require('./Type');
- module.exports = function GetIteratorFromMethod(obj, method) {
- if (!IsCallable(method)) {
- throw new $TypeError('method must be a function');
- }
- var iterator = Call(method, obj);
- if (Type(iterator) !== 'Object') {
- throw new $TypeError('iterator must return an object');
- }
- var nextMethod = GetV(iterator, 'next');
- return {
- '[[Iterator]]': iterator,
- '[[NextMethod]]': nextMethod,
- '[[Done]]': false
- };
- };
|