Restarting a Generator in Javascript
问题 In node (0.11.9, with the --harmony flag), how do I restart a generator after it finishes? I tried doing generator.send(true); but it says the send() method doesn't exists. 回答1: A bit late, but this is just a FYI. At the moment, the send method is not implemented in Node, but is in Nightly (FF) - and only in some way. Nightly: If you declare your generator without the *, you'll get an iterator that has a send method: var g = function() { var val = yield 1; // this is the way to get what you