Created
June 6, 2013 17:59
-
-
Save kourge/5723530 to your computer and use it in GitHub Desktop.
The ES6 spec states that calling the send method on a generator should result in an object. So long as the generator is yielding more values, the object is { value: v, done: false } where v is the value yielded. When the generator stops, the object is { value: undefined, done: true }. Firefox has had a preliminary implementation of generators th…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| this.Generator && (function(g, global) { | |
| var __send = g.prototype.send; | |
| g.prototype.send = function send(value) { | |
| var result = __send.call(this, value); | |
| if (result.done) { | |
| throw new StopIteration(); | |
| } | |
| return result.value; | |
| }; | |
| function StopIteration(message) { | |
| this.message = message; | |
| } | |
| StopIteration.prototype = new global.Error(); | |
| StopIteration.prototype.constructor = StopIteration; | |
| StopIteration.prototype.name = "StopIteration"; | |
| global.StopIteration = StopIteration; | |
| })(this.Generator, this); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment