function *x(){
    for(let y = 0; y < 10; y++)
        yield y
}


//Main
const value = x()
while(true){
    const nextVal = value.next()
    if(nextVal.done)   
        break
    console.log(nextVal.value)
}