如何在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/)
我感到困惑。