GetIteratorDirect.js 495 B

123456789101112131415161718
  1. 'use strict';
  2. var $TypeError = require('es-errors/type');
  3. var Get = require('es-abstract/2023/Get');
  4. var Type = require('es-abstract/2023/Type');
  5. module.exports = function GetIteratorDirect(obj) {
  6. if (Type(obj) !== 'Object') {
  7. throw new $TypeError('Assertion failed: `obj` must be an Object');
  8. }
  9. var nextMethod = Get(obj, 'next'); // step 2
  10. var iteratorRecord = { '[[Iterator]]': obj, '[[NextMethod]]': nextMethod, '[[Done]]': false }; // step 3
  11. return iteratorRecord; // step 4
  12. };