generators throws exception
See original GitHub issueI try to use ES6 generators in a new clean ember-cli project but it doesn’t run in the browser because of Uncaught ReferenceError: regeneratorRuntime is not defined
. It seems there is a missing global/dependency in my service?
function* testGenerator(fixtures) {
for(let i = 0, max = fixtures.length; i < max; ++i) {
yield foo(fixtures[i]);
}
}
6to5 generates this source for my example:
var testGenerator = regeneratorRuntime.mark(function testGenerator(fixtures) {
var i, max;
return regeneratorRuntime.wrap(function testGenerator$(context$1$0) {
while (1) switch (context$1$0.prev = context$1$0.next) {
case 0:
i = 0, max = fixtures.length;
case 1:
if (!(i < max)) {
context$1$0.next = 7;
break;
}
context$1$0.next = 4;
return foo(fixtures[i]);
case 4:
++i;
context$1$0.next = 1;
break;
case 7:
case "end":
return context$1$0.stop();
}
}, testGenerator, this);
});
I’m using ember-cli@0.1.12
and ember-cli-6to5@3.0.0
Issue Analytics
- State:
- Created 9 years ago
- Comments:11 (5 by maintainers)
Top Results From Across the Web
python - Handle an exception thrown in a generator
When a generator throws an exception, it exits. You can't continue consuming the items it generates. Example:
Read more >Generator.prototype.throw() - JavaScript - MDN Web Docs
The throw() method of a generator acts as if a throw statement is inserted in the generator's body at the current suspended position,...
Read more >Generator::throw - Manual - PHP
Throws an exception into the generator and resumes execution of the generator. The behavior will be the same as if the current yield...
Read more >PEP 288 – Generators Attributes and Exceptions
This PEP proposes to enhance generators by providing mechanisms for raising ... Add a .throw(exception) method to the generator interface:.
Read more >Exception Handling and Generators in Python - ScholarBasta
Exception handling is a way of handling exceptions that occur during the runtime of the program and causes the program flow to terminate....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For those who are running into this issue, see: https://github.com/babel/ember-cli-babel#polyfill
ok, thanks very much, I’ll try this. Just before you posted this, I was able to get my generator working by using the Bower package
babel-polyfill
and then including in the Brocfile:app.import('bower_components/babel-polyfill/browser-polyfill.js', { prepend: true });