by sync · 12y ago · 0 comments
function *() {
try {
let body = yield request("https://x.io/");
return yield request("https://x.io/?q=" + body.hash);
} catch (e) {
// do what you like with the error
}
} ->
try
body = yield request "https://x.io/"
yield request "https://x.io/?q=#{body.hash}"
catch e
# do what you like with the error
... the salient bit being that there's no need to declare a generator function as a "special" type of function different from any other — a generator is simply a function that yields.