JeffreyZhao / wind

Asynchronous flow control in JavaScript, with JavaScript.
http://windjs.org/
1.54k stars 238 forks source link

与Commander的兼容性问题 #74

Open xingrz opened 11 years ago

xingrz commented 11 years ago

Command.js.choose(list, fn)方法,直接fromCallback绑定会报TypeError: undefined is not a function(似乎是回调fn没有传过去),但像下面那样自己包多一层function就没事。

var program   = require('commander');

var Wind = require('wind'),
    Binding = Wind.Async.Binding;

/* this dosen't work */
program.chooseAsync = Binding.fromCallback(program.choose);

/* this does work  */
/*program.chooseAsync = Binding.fromCallback(function(list, fn) {
  program.choose(list, fn);
});*/

eval(Wind.compile('async', function () {
  var list = ['javascript', '.net', 'php', 'ruby', 'python'];
  var choise = $await(program.chooseAsync(list));
  console.log('you just chose: %s', choise);
}))().start();