Koa / Co / Bluebird或Q / Generators / Promises / Thunks互动?(Node.js)[关闭]

我正在研究部分使用Koa构建Web应用程序的方法,但是我对如何在-和应用-支持“使异步操作更容易”的技术/方法(包括下面列出)。

总体而言,网上关于该主题的不同指导仍然使事情变得模糊,尤其是在不断发展的最佳实践或至少更好的最佳实践以及在什么情况下。在网络上几乎没有或没有任何东西可以将其全部置于上下文中。

我希望对这个大屁股的帖子的反应可以纠正这个问题同样,也许以下问题可以激发某人撰写详尽的博客文章或类似内容以解决此问题。我的感觉是,我什至没有一个可以从中受益的人。

因此,如果聪明的社区可以帮助回答以下有关以下所列技术的问题(以下以粗体显示),我将感到高兴:

-a)它们如何以及在什么情况下(如适用)相互补充,补充,替代和/或重叠的解决方案?

-b)在速度性能,错误处理的简便性和调试的简易性方面,它们的权衡取舍是什么?

-c)什么时候,在哪里以及为什么使用“这种”技术与“那种”技术,技术组合和/或方法更好?

-d)哪些技术或方法(如有)可能是“暗淡的星星”。

(希望可以很好地解释答案的观点。)

==============================

技术:

*柯阿*

我的理解:

Koa是构建Node应用程序的最小基础,这些应用程序旨在利用ECMAScript-6功能,尤其是生成器。

*合作*

我的理解:

-- 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 is intrinsically part of 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?

-- Could Co be replaced in Koa with some other like generator library if there is/was a better one? Are there any?

* 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.
-- They have some further non-spec convenience utilities for facilitating the use promises, such as Bluebird's promisfyAll utility.

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?

-- 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?

* Thunks and Promises *

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.

Specific questions:

-- Pro and cons to using something like Bluebird's promisfy, versus say using Thunkify (github com/visionmedia/node-thunkify)?

==============================

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):

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

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

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

-- d) blog.peterdecroos . com/blog/2014/01/22/javascript-generators-first-impressions (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!