123456789101112131415161718192021222324252627 |
- 'use strict';
- var $TypeError = require('es-errors/type');
- var CreateIterResultObject = require('es-abstract/2023/CreateIterResultObject');
- var GeneratorValidate = require('./GeneratorValidate');
- var SLOT = require('internal-slot');
- module.exports = function GeneratorResume(generator, value, generatorBrand) {
- var state = GeneratorValidate(generator, generatorBrand);
- if (state === 'completed') {
- return CreateIterResultObject(void undefined, true);
- }
- if (state !== 'suspendedStart' && state !== 'suspendedYield') {
- throw new $TypeError('Assertion failed: generator state is unexpected: ' + state);
- }
- var genContext = SLOT.get(generator, '[[GeneratorContext]]');
- SLOT.set(generator, '[[GeneratorState]]', 'executing');
- var result = genContext(value);
- return result;
- };
|