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:
700 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 |
|
---|
3 | var $TypeError = require('es-errors/type');
|
---|
4 |
|
---|
5 | var SLOT = require('internal-slot');
|
---|
6 |
|
---|
7 | module.exports = function GeneratorValidate(generator, generatorBrand) {
|
---|
8 | SLOT.assert(generator, '[[GeneratorState]]'); // step 1
|
---|
9 | SLOT.assert(generator, '[[GeneratorBrand]]'); // step 2
|
---|
10 |
|
---|
11 | var brand = SLOT.get(generator, '[[GeneratorBrand]]');
|
---|
12 | if (brand !== generatorBrand) {
|
---|
13 | throw new $TypeError('Assertion failed: generator brand is unexpected: ' + brand);
|
---|
14 | }
|
---|
15 | SLOT.assert(generator, '[[GeneratorContext]]'); // step 4
|
---|
16 | var state = SLOT.get(generator, '[[GeneratorState]]'); // step 5
|
---|
17 | if (state === 'executing') {
|
---|
18 | throw new $TypeError('generator is executing');
|
---|
19 | }
|
---|
20 |
|
---|
21 | return state; // step 7
|
---|
22 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.