为什么我不能在节点v0.11.11中使用Promise? [英] Why can't I use Promise in node v0.11.11?

查看:64
本文介绍了为什么我不能在节点v0.11.11中使用Promise?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是搞乱节点的 v0.11 分支,我想知道为什么我不能使用原生ES6 承诺对象,即使 - 和谐已开启。

I'm just messing around with the v0.11 branch of node, and I'm wondering why I can't use the native ES6 Promise object, even with --harmony turned on.

我的普通铬浏览器:

Google Chrome    32.0.1700.77 (Official Build 244503) 
JavaScript       V8 3.22.24.10

支持它们,而node.js v0.11.11 告诉我:

Supports them, and node.js v0.11.11 is telling me:

> process.versions.v8
'3.22.24.19'

那么给出了什么?

推荐答案

原生承诺在,您现在可以使用它们。它们比Bluebird这样的库仍然更慢,更难调试,但它们就在那里。

Native Promises are in, you can now use them. They're still slower and harder to debug than libraries like Bluebird but they're there.

目前在Chrome中的承诺是DOM期货。此外,他们是非常实验性的,API可能会发生变化(在很多时候讨论过这个问题)。

Promises currently in Chrome are DOM Futures. Also, they're very experimental and the API might change (it's quite heavily discussed atm).

考虑使用蓝鸟承诺,因为它们更快,更好的堆栈跟踪并且稳定

它比像 Q 这样的库快得多(两个订单)它具有更好的堆栈跟踪和完全符合规范的API。您当然也可以自己编译node和v8 - 有 v8本身的承诺

It is consdierably faster than libraries like Q (two orders of magnitude faster) it has much better stack traces and a completely spec compliant API. You may of course also compile node and v8 yourself - there are promises in v8 itself.

ES6中有承诺,它们还没有定居 - 使得Chrome的人都颇为恼怒太

There are promises in ES6, they're just not 'settled' yet - making the Chrome people are quite angry too

它们也被认为是DOM的一部分,因为未来的DOM API将使用promises。

They're considered part of the DOM too because future DOM APIs will use promises.

这篇关于为什么我不能在节点v0.11.11中使用Promise?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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