main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
850 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 |
|
---|
3 | var $TypeError = require('es-errors/type');
|
---|
4 |
|
---|
5 | var CreateIterResultObject = require('es-abstract/2024/CreateIterResultObject');
|
---|
6 | var GeneratorValidate = require('./GeneratorValidate');
|
---|
7 |
|
---|
8 | var SLOT = require('internal-slot');
|
---|
9 |
|
---|
10 | module.exports = function GeneratorResume(generator, value, generatorBrand) {
|
---|
11 | var state = GeneratorValidate(generator, generatorBrand); // step 1
|
---|
12 | if (state === 'completed') {
|
---|
13 | return CreateIterResultObject(void undefined, true); // step 2
|
---|
14 | }
|
---|
15 |
|
---|
16 | if (state !== 'suspendedStart' && state !== 'suspendedYield') {
|
---|
17 | throw new $TypeError('Assertion failed: generator state is unexpected: ' + state); // step 3
|
---|
18 | }
|
---|
19 |
|
---|
20 | var genContext = SLOT.get(generator, '[[GeneratorContext]]');
|
---|
21 |
|
---|
22 | SLOT.set(generator, '[[GeneratorState]]', 'executing'); // step 7
|
---|
23 |
|
---|
24 | var result = genContext(value); // steps 5-6, 8-10
|
---|
25 |
|
---|
26 | return result;
|
---|
27 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.