source: imaps-frontend/node_modules/es-iterator-helpers/aos/GeneratorValidate.js@ d565449

main
Last change on this file since d565449 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
3var $TypeError = require('es-errors/type');
4
5var SLOT = require('internal-slot');
6
7module.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.