The following code:
function* logGenerator() {
console.log(0);
console.log(1, yield);
console.log(2, yield);
console.log(3, yield);
}
var gen = logGenerator();
// the first call of next executes from the start of the function
// until the first yield statement
gen.next(); // 0
gen.next('pretzel'); // 1 pretzel
gen.next('california'); // 2 california
gen.next('mayonnaise'); // 3 mayonnaise
I have taken this code from the following site in the Passing arguments into Generators section. I am trying to produce this code in the MarkLogic Qconsole Javascipt Site
The output that I get for the first three items is
"done": false
"done": false
"done": false
"done": true
//instead of the expected output
gen.next(); // 0
gen.next('pretzel'); // 1 pretzel
gen.next('california'); // 2 california
gen.next('mayonnaise'); // 3 mayonnaise
Does anyone have any ideas why this behavior or is there anything different I must do?