done() 与 bluebird 的 spread() 之间的区别

Difference between done() vs spread() of bluebird

嗨,我不明白 spread() 与 JavaScript.Even 的 bluebird 库的 done() 有什么区别 bluebird 是 Q 的包装器,所以 Q 也同时具有在它的库中运行。

任何人都可以解释一下这两个函数之间的区别是什么吗?

提前致谢!

Even bluebird is wrapper of Q so…

哦,绝对不是。我希望这不会使您的问题无效?

I am not getting what is the difference of spread() vs done()?

API 文档可能会有很大帮助:

  • spread是“就像调用.then一样,但是实现值或者拒绝原因必须是一个数组,被压扁为形式参数处理程序。"

    如果您有数组的承诺,spread 将使用 多个参数调用您的回调

    这与 Q 所做的一样:spread 是“ 类似于 then,但 "spreads" 数组变成了可变参数实现处理程序。"

  • done 是“.then(),但是任何 未处理的拒绝 都会被抛出作为错误。[...它]用于显式标记承诺链的结尾。"

    可以在 error handling documentation. Notice that bluebird is quite different from Q here, as it smartly figures out unhandled rejection and reports them on its own 中找到有关这方面的更多详细信息 - 您不必明确告诉它在拒绝到达某个点时抛出全局错误。

    将其与 Q's done documentation 进行比较,后者建议不受限制地使用。

如您所见,spreaddone是完全不同的方法,目的不同。此外,done 模式在 Bluebird 和 Q 之间有所不同。