send("asker","asker get ready...");// call first .next()
send("knocker","knocker go!");// start the conversation
run();
}
send=(name,msg)=>{
console.log(msg);
queue.push([name,msg]);
}
run=()=>{
while(queue.length){
let[name,msg]=queue.shift();
players[name].next(msg);
}
}
knocker=function*(){
send("asker","knock knock");
letquestion=yield;
if(question!=="who's there?")return;
send("asker","gene");
question=yield;
if(question!=="gene who?")return;
send("asker","generator!");
}
asker=function*(){
letknock=yield;
if(knock!=="knock knock")return;
send("knocker","who's there?");
letanswer=yield;
send("knocker",`${answer} who?`);
}
Purpose-built for displays of data
Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.