在Windows上使用Node.js中的promises

时间:2011-11-18 14:04:27

标签: javascript node.js promise

如何在Windows上运行的Node.js上使用promises?对于我的生活,我似乎无法找到任何工作的例子......

例如,这样的东西不起作用:

var pinput = new Promise(
   function(fulfillPromise, breakPromise) {
     var btn = document.getElementById("button");
     var txt = document.getElementById("txt");
     btn.onclick = function() {
       fulfillPromise(txt.value);
     }
   }
);

pinput.whenOnly(function(value) { alert(value); });

投掷要求也无济于事:

Promise = require('promise');

我得到的只是:

ReferenceError: promise is not defined

Error: Cannot find module 'Promise'

我似乎无法从最新的API中找到承诺......(http://nodejs.org/docs/latest/api/)

我感到困惑。

1 个答案:

答案 0 :(得分:1)

我相信承诺已被删除。 See this Google Groups post了解更多信息。