日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Koa / Co / Bluebird or Q / Generators / Promises / Thunks 的相互关系

發(fā)布時間:2023/12/20 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Koa / Co / Bluebird or Q / Generators / Promises / Thunks 的相互关系 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

經(jīng)常游蕩在 SO 的我總能發(fā)現(xiàn)許多好問題和好答案。它們的“好”不僅僅在于知識的價值,更可貴之處在于如何表達(dá):如何“提問”/如何“回答”。不久前我在 SF 發(fā)了一篇 WebComponents 和 React 的對比 就是一個很典型的范例,今天我又發(fā)現(xiàn)看到這樣的一篇,不敢獨享,略做翻譯繼續(xù)奉獻(xiàn)給諸位。(唯一的回答比較長還沒翻譯完且我也在等待更好的回答,等有時間會補(bǔ)充)

Koa / Co / Bluebird or Q / Generators / Promises / Thunks interplay? (Node.js)

Koa / Co / Bluebird or Q / Generators / Promises / Thunks 的相互關(guān)系(影響/作用)?

I'm investigating building a web app in part with Koa, but I don't quite have a handle on the hows, whens, and whys of choosing between - and applying - the range of supportive "making async easier" technologies/approaches (listed below).
我正在為了創(chuàng)建 web 應(yīng)用時和 Koa 有關(guān)的部分做調(diào)研,但我對于一系列“讓異步編程更輕松”的技術(shù)/方法(下文列出),很難抉擇如何、何時、以及為何選擇且運(yùn)用。

Overall the disparate guidance on the web about this subject still leaves things blurry, especially in respect to evolving best practices, or at least better ones, and under what scenarios. There seems to be little or nothing on the web that puts it all in context.
盡管網(wǎng)絡(luò)上有著各式各樣的關(guān)于該主題的指導(dǎo),但涉及到在各種情景下的最佳實踐,或者較好實踐的方面還是不夠清晰??雌饋砭W(wǎng)上幾乎沒有“百科全書”。

I'm hoping the responses to this big arse sprawling post can correct that. Also maybe the questions below can inspire someone to write a thorough blog post or the like to address this matter. My sense is I'm not even close to the only one who would benefit from that.
我寄希望于針對我這篇“裹腳布”式問題的回復(fù)可以改變這一現(xiàn)狀。同時也希望下面的問題可以激發(fā)某人寫一篇博客或什么的將其囊括總結(jié)。我感覺因此收益的絕對不止是我一個人。

So I'd be pleased if the bright community could help answer and provide clarity to the following questions in respect to the technologies listed below (in bold type):
所以我很高興若有人能從如下角度針對后面的問題(黑體)提供清楚的回答:

a) How, and under what circumstance (as applicable) are they complements, supplements, substitutes, and/or overlapping solutions to one another?
a) 在何種(可適用的)情形下,它們相互之間可怎樣補(bǔ)充、替換、并且/或者彼此重復(fù)?

b) What are their trade-offs in respect to speed-performance, error handling ease, and debugging ease?
b) 在速度/性能,便于錯誤處理和便于調(diào)試這幾方面,它們各自的利弊是什么?

c) When, where, and why may it be better to use "this" versus "that" technology, technologies-combo, and/or approach?
c) 在何時,何處用“這個”代替“那個”技術(shù)/技術(shù)組合/方法會更好,以及原因為何?

d) Which technologies or approaches, if any, may be "dimming stars".
d) 哪一種技術(shù)或方法,如果有的話,可能已經(jīng)是“昨日黃花”。


Technologies:
技術(shù):

Koa

My understanding:
我的理解:

Koa is a minimal foundation for build Node apps geared for taking advantage of ECMAScript-6 features, one feature in particular being generators.
Koa 是受益于 ES6特性,特別是 Generators 特性的用來開發(fā) Node 應(yīng)用的最小化基礎(chǔ)框架。

Co

My understanding:
我的理解:

  • Co is a library of utilites for running ECMAScript-6 generators (which are native to Node .011 harmony), with the goal to allieve some/much(?) of the need to write boilerplate code for running and managing generators.
    Co 是運(yùn)行 ES6 Generators(Node .011 harmony 模式下原生支持)的工具類庫,其目標(biāo)是幫助編寫部分/更多(?)的用于運(yùn)行和管理 generators 的模版代碼。

  • Co is intrinsically part of Koa(?).
    Co 本質(zhì)上是 Koa 的一部分(?)。

Specific questions:
針對性問題:

  • If and how does one use Co differently in Koa than in a non-Koa context. In other words, does Koa wholly facade Co?
    能否且若能則如何讓 Co 在非 Koa 的場合下以不同于 Koa 的方式使用?換言之,Koa 是否只是換了一個“馬甲”的 Co?

  • Could Co be replaced in Koa with some other like generator library if there is/was a better one? Are there any?
    在 Koa 當(dāng)中有能代替 Co 的其他 generator 類庫嗎?

Promise Libraries such as "Q" and Bluebird

My understanding:
我的理解:

  • They are in a sense "polyfills" for implmententing the Promises/A+ spec, if and until Node natively runs that spec.
    它們都是 Promises/A+ 規(guī)范的 polyfills 實現(xiàn),當(dāng)且直到 Node 原生實現(xiàn)了該規(guī)范。

  • They have some further non-spec convenience utilities for facilitating the use promises, such as Bluebird's promisfyAll utility.
    它們實現(xiàn)了一些規(guī)范外的便利方法以便更好的使用 promises,比如 Bluebird 的 promisfyAll。

Specific questions:
針對性問題:

  • My understanding is the ECMAScript-6 spec does/will largely reflect the Promises/A+ spec, but even so, Node 0.11v harmony does not natively implement Promises. (Is this correct?) However when it does, will technologies such as Q and Bluebird be on their way out?
    我理解中的 ES6 規(guī)范(將)會大量體現(xiàn) Promises/A+ 規(guī)范,可即便如此,Node 0.11v harmony 沒有原生 Promises 實現(xiàn)(對嗎?)。若將來實現(xiàn)了,像 Q 和 Bluebird 這樣的技術(shù)是不是就要過時了?

  • I've read something to the effect that "Q" and Bluebird support generators. What does this mean? Does it mean in part that, for example, they to some degree provided the same utility as Co, and if so to what degree?
    我讀到過一些東西說 Q 和 Bluebird 支持 generators。這是什么意思?是不是意味著在某種程度上它們提供了和 Co 一樣的功能?如果是的化,一樣到了何種程度?

Thunks and Promises
(譯注:此二者皆為術(shù)語不做翻譯更佳)

I think I have an fair handle on what they are, but hoping someone can provide a succinct and clear "elevator pitch" definition on what each is, and of course, as asked above, to explain when to use one versus the other -- in a Koa context and not in it.
我想我對此二者已經(jīng)理解了,不過還是希望有誰能提供一個簡明扼要的“電梯推介”(譯注:即在做個電梯的時間里,如一分鐘內(nèi),說清楚一個概念),且能解釋下二者的對比——在使用和不使用 Koa 的情形下。

Specific questions:
針對性問題:

  • Pro and cons to using something like Bluebird's promisfy, versus say using Thunkify (github com/visionmedia/node-thunkify)?
    對比使用 Bluebird 等 promise 式的庫和 thunk 式的庫(如 https://github.com/visionmedia/node-thunkify)之間的優(yōu)點和缺點

To give some further context to this post and its questions, it might be interesting if Koa techniques presented in the following webpages could be discussed and contrasted (especiallly on a pros vs cons basis):
為了對本問題提供更多的背景資料,下列涉及 Koa 技術(shù)的資料若能一并加以探討和對比(特別是優(yōu)劣比較)那就再好不過了:

  • a) http://www.marcusoft.net/2014/03/koaintro.html (Where's the thunks or promises, or am I not seeing something?)

  • b) https://strongloop.com/strongblog/node-js-express-introduction-koa-js-... (Again, where's the thunks or promises?)

  • c) http://github.com/koajs/koa/blob/master/docs/guide.md (What does the "next" argument equate to, and what set it and where?)

  • d) http://blog.peterdecroos.com/blog/2014/01/22/javascript-generators-fir... (Not in a Koa context, but presents the use of Co with a promise library (Bluebird), so I'm assuming the technique/pattern presented here lends itself to usage in Koa(?). If so, then how well?

Thanks all!

總結(jié)

以上是生活随笔為你收集整理的Koa / Co / Bluebird or Q / Generators / Promises / Thunks 的相互关系的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 亚洲成人av电影网站 | 欧美猛交免费 | 贝利弗山的秘密在线观看 | 欧美性猛交xxxx免费看久久久 | 日日日插插插 | 奶水喷溅虐奶乳奴h文 | 久久偷拍免费视频 | 久久综合狠狠综合久久综合88 | 精品一区二区三区日韩 | 国产鲁鲁视频在线观看特色 | 亚洲伦理在线观看 | 国产拍拍拍拍拍拍拍拍拍拍拍拍拍 | 丰满人妻av一区二区三区 | 国产一级视频免费观看 | 日韩爱爱网| a在线视频| 毛片无遮挡高清免费观看 | www男人天堂 | 女生扒开尿口让男生桶 | 国产亚洲精品网站 | 啪啪一级片 | 国产专区av| 黑人专干日本人xxxx | 大j8福利视频导航 | 国产永久免费无遮挡 | 福利在线免费 | 香蕉视频在线观看黄 | 高清av一区二区三区 | 日本视频在线免费 | 手机看片一区二区三区 | 波多野结衣一区在线 | 色www| 天堂在线国产 | 高清乱码免费网 | 久久99精品波多结衣一区 | 国产3区| 日韩有码在线视频 | 精品麻豆一区二区 | 久久av一区二区三区亚洲 | 午夜激情电影在线观看 | 久久亚洲AV成人无码国产人妖 | 久久伊人影院 | 色图综合 | 国产精品久久久久影院 | 欧美日韩国产一区 | 欧美456 | 原创露脸88av | 天堂在线1 | 亚洲激情a | 日本免费在线观看视频 | 久久久久久久久久久久久女国产乱 | www.色婷婷 | 欧美黄色一级片视频 | 欧美亚色 | 又嫩又硬又黄又爽的视频 | 欧美精品一区视频 | 在线成人福利 | 经典三级av在线 | 久久妇女| 国产黄色大片免费看 | 久久香蕉网站 | 久久露脸国语精品国产91 | 伊人网址 | 交专区videossex非洲 | 久久精品国产免费 | 91一区二区三区四区 | 欧美亚洲色综久久精品国产 | 99久久久无码国产精品性 | 日韩欧美理论片 | 在线看你懂| 领导揉我胸亲奶揉下面 | 97精品熟女少妇一区二区三区 | 色呦呦呦呦 | 亚洲七区| 99re在线视频免费观看 | 日韩人妻精品一区二区三区视频 | 玖玖在线 | 久草视频在线资源站 | 欧美自拍偷拍一区二区 | 精品国产av无码一区二区三区 | 韩国精品视频在线观看 | 香蕉久久国产 | 国产成人8x视频一区二区 | 国产免费一区二区三区三州老师 | 日本欧美一区二区三区 | 国产成人久久 | 亚洲精品久久久久av无码 | 亚洲日本天堂 | 美女被男人插 | 豆花视频在线 | 成人mv | 国产做爰免费视频观看 | 怡春院视频 | 日本精品一区二区在线观看 | 欧美激情四区 | 婷婷黄色网 | 激情无遮挡 | 91久久久久久 | 国产情侣在线播放 |