我正在尝试使用通过咖啡脚本编写的 github API 做一些事情。我对它很陌生,我在这个块上遇到了麻烦。
getRepos: (user)->
this.github.repos.getFromUser(
user: user,
type: "all",
sort: "updated",
direction: "desc"
(err,res)-> console.log(JSON.stringify(res))
)
目前,它正在编译为
getRepos: function(user) {
return this.github.repos.getFromUser({
user: user
}, {
type: "all",
sort: "updated",
direction: "desc"
}, function(err, res) {
return console.log(JSON.stringify(res));
});
而我不想要用户:用户之后的额外括号,那就是它应该看起来像这样:
getRepos: function(user) {
return this.github.repos.getFromUser({
user: user,
type: "all",
sort: "updated",
direction: "desc"
}, function(err, res) {
return console.log(JSON.stringify(res));
});
我对咖啡脚本缺少什么?
编辑:这是完整的代码
GitHubApi = require("node-github");
gitLoader =
github: new GitHubApi({
version: "3.0.0",
timeout: 5000
});
authenticate: ->
this.github.authenticate({
type: "basic",
username: username,
password: password
})
getRepos: (user)->
this.github.repos.getFromUser(
user: user,
type: "all",
sort: "updated",
direction: "desc"
(err,res)-> console.log(JSON.stringify(res))
)
getFollowers: ->
this.github.user.getFollowingFromUser(
user: "example",
(err, res)->console.log(JSON.stringify(res));
)
编辑2:认为它一定是某种间距问题。当我复制粘贴从编辑器复制的副本时,它编译正确。= /