IteratorComplete.js 498 B

123456789101112131415161718
  1. 'use strict';
  2. var GetIntrinsic = require('get-intrinsic');
  3. var $TypeError = GetIntrinsic('%TypeError%');
  4. var Get = require('./Get');
  5. var ToBoolean = require('./ToBoolean');
  6. var Type = require('./Type');
  7. // https://ecma-international.org/ecma-262/6.0/#sec-iteratorcomplete
  8. module.exports = function IteratorComplete(iterResult) {
  9. if (Type(iterResult) !== 'Object') {
  10. throw new $TypeError('Assertion failed: Type(iterResult) is not Object');
  11. }
  12. return ToBoolean(Get(iterResult, 'done'));
  13. };