/**
* async的執行原理
* 其實就是自動執行generator函式
* 暫時不考慮genertor的編譯步驟(更複雜)
*/const
getdata=(
)=>
newpromise
(resolve =>
settimeout((
)=>
resolve
("data"),
1000))
// 這樣的乙個async函式 應該再1秒後列印data
async
function
test()
// async函式會被編譯成generator函式 (babel會編譯成更本質的形態,這裡我們直接用generator)
function
*testg()
function
asynctogenerator
(generatorfunc)
catch
(error
)const
= generatorresult
if(done)
else
,function
onreject
(err),)
}}step
("next")}
)}}const testgasync =
asynctogenerator
(testg)
testgasync()
.then
(result =>
)
如何實現乙個窗體
如何實現乙個窗體 jframe 1.建乙個類窗體例如 swingui extands jframe 2.在main函式中初始化例項swingui frame new swingui frame.settitle frame.addwindowlistener listener frame.pack ...
如何實現乙個迴圈佇列
下面是乙個迴圈佇列的完整實現,歡迎讀者朋友參考和指正 template class cyclicqueue cyclicqueue cyclicqueue const cyclicqueue copy m poppos 0 m count 0 cyclicqueue operator const c...
如何實現乙個迴圈佇列
template class cyclicqueue cyclicqueue cyclicqueue const cyclicqueue copy m poppos 0 m count 0 cyclicqueue operator const cyclicqueue other return thi...