Skip to content

Instantly share code, notes, and snippets.

@kourge
Created June 6, 2013 17:59
Show Gist options
  • Select an option

  • Save kourge/5723530 to your computer and use it in GitHub Desktop.

Select an option

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.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