Promises / A +实现如何变化? [英] How do Promises/A+ implementations vary?

查看:109
本文介绍了Promises / A +实现如何变化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

规范库的哪些方面的规范涵盖?实现之间有什么不同?

What aspects of a promise library does the spec not cover? What kind of things vary between implementations?

请说明实际差异的例子(例如Bluebird和Q之间)。

Please illustrate with examples of actual differences (eg between Bluebird and Q).

推荐答案

几乎所有事情。 Promises / A +规范旨在实现承诺互操作性,它的构建使得承诺库(现在,本机承诺)可以彼此交谈。我们的想法是可以预测承诺的行为方式,并定义承诺如何被其他库同化

Almost everything. The Promises/A+ spec is aimed for promise interoperability, it's built so promise libraries (and now, native promises) can talk to each other. The idea is for it to be possible to predict how a promise behaves and to define how promises are assimilated by other libraries.

引用规范:


此规范详细说明然后方法的行为,提供可互操作的基础所有Promises / A +符合承诺的实现都可以依赖于提供。因此,应该认为规范非常稳定。尽管Promises / A +组织可能偶尔会修改此规范,并进行微小的向后兼容更改以解决新发现的极端情况,但只有经过仔细考虑,讨论和测试后,我们才会集成大型或后向不兼容的。最后,核心Promises / A +规范不涉及如何创建,实现或拒绝承诺,而是选择专注于提供可互操作的方法。配套规范中的未来工作可能涉及这些主题。

This specification details the behavior of the then method, providing an interoperable base which all Promises/A+ conformant promise implementations can be depended on to provide. As such, the specification should be considered very stable. Although the Promises/A+ organization may occasionally revise this specification with minor backward-compatible changes to address newly-discovered corner cases, we will integrate large or backward-incompatible only after careful consideration, discussion, and testing. Finally, the core Promises/A+ specification does not deal with how to create, fulfill, or reject promises, choosing instead to focus on providing an interoperable then method. Future work in companion specifications may touch on these subjects.

以下内容不包括:


  • 创建承诺(即承诺构造函数规范)。

  • 承诺聚合(尽管大多数实现支持 .all )。

  • 进展(这是< a href =https://github.com/promises-aplus/progress-spec>进展规范,即将被替换为imo)。

  • 取消(即取消规范)。

  • 未处理的拒绝监控(没有规范) ,但有一个检查讨论)。

  • 堆栈跟踪。

  • Creating a promise (that's the promise constructor spec).
  • Promise aggregation (although most implementations support .all).
  • Progression (that's the progression spec, which will soon be replaced imo).
  • Cancellation (that's the cancellation spec).
  • Unhandled rejection monitoring (there is no spec, but there is an inspection discussion).
  • Stack traces.

Bluebird和Q for例如,完全是Promises / A +投诉,但在很多方面都有所不同:

Bluebird and Q for example, are both completely Promises/A+ complaint but differ on a lot of these:


  • 下一个Q,v2引入估算,其中Bluebird打算最终放弃升级,转而支持C#的IProgress。

  • 通常在Q中使用延迟来创建一个承诺(尽管它现在提供了一个promise构造函数变体),Bluebird鼓励承诺构造函数。

  • Bluebird具有更强大和更强大的promisification功能,将整个回调API转换为单个命令中的promise。 Q作者Kris构建了Q-IO,它手动宣传文件系统和http模块。

  • Bluebird允许通过<$绑定值c $ c> .bind 和promise数组方法( .map .reduce .filter 等)。

  • Q具有异步队列等原语,并且考虑到了通过Q连接的RPC,

  • Bluebird大约快100倍,具有更好的堆栈跟踪,和自动未处理的拒绝检测。它还会为每个承诺消耗更少的RAM内存。

  • The next Q, v2 introduces estimation, where Bluebird intends to deprecate progression eventually in favor of something like C#'s IProgress.
  • Creating a promise is usually done with deferreds in Q (although it now offers a promise constructor variant), Bluebird encourages the promise constructor.
  • Bluebird has more robust and stronger promisification abilities, turning a whole callback API to promises in a single command. Q author Kris built Q-IO which manually promisifies the filesystem and http modules.
  • Bluebird allows scoped binding of this value via .bind, and promise array methods (.map,.reduce,.filter etc).
  • Q has primitives like asynchronous queues, and RPC via Q-connection in mind,
  • Bluebird is about 100 times faster, has better stack traces, and automatic unhandled rejection detection. It also consumes a lot less RAM memory per promise.

这是另一个参考资料

这篇关于Promises / A +实现如何变化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆