开发者

Require a library with configuration in CoffeeScript?

开发者 https://www.devze.com 2023-04-10 22:26 出处:网络
I\'d like to use CoffeeScript with Nano.js, a minimalistic CouchDB module. In JavaScript, the requirements are:

I'd like to use CoffeeScript with Nano.js, a minimalistic CouchDB module. In JavaScript, the requirements are:

var nano开发者_Python百科 = require('nano')('http://127.0.0.1:5984');

However, there is no documentation on how to write this in CoffeeScript?

nano = require 'nano', 'http://127.0.0.1:5984'

Results in:

nano = require('nano', 'http://127.0.0.1:5984');

Which doesn't work.


Since you are calling a function which calls a function, doing what you tried is ambiguous. Parentheses are required in CoffeeScript to resolve ambiguity. Have you tried this:

nano = require('nano')('http://127.0.0.1:5984')

Or, if you really want to go without parens, you could do this:

nano = require 'nano'
nano = nano 'http://127.0.0.1:5984'

Or just

nano = require('nano') 'http://127.0.0.1:5984'
0

精彩评论

暂无评论...
验证码 换一张
取 消