Skip to content

Instantly share code, notes, and snippets.

View sauravdroid's full-sized avatar

Saurav Biswas sauravdroid

View GitHub Profile
@ericelliott
ericelliott / passing-values-to-generators.js
Created May 20, 2016 07:14
Passing values into generators through `.next()`
function* crossBridge() {
const reply = yield 'What is your favorite color?';
console.log(reply);
if (reply !== 'yellow') return 'Wrong!'
return 'You may pass.';
}
{
const iter = crossBridge();
const q = iter.next().value; // Iterator yields question