class JSChannel{
constructor(){
//todo
}
output(){
//todo
}
input(item){
//todo
}
}
var chan = new JSChannel()
chan.input(1)
chan.input(2)
chan.input(3)
async function runloop(){
while(1){
var v = await chan.output()
console.log(v)
}
}
runloop()
setInterval(
function(){
chan.input(new Date())
},1000
)
//实现类似go channel的功能 一端输入一端输入,没有输入时候停住
//输出1 2 3 然后一秒出一次时间