在这个文件中:https ://github.com/josh/nack/blob/master/src/server.coffee
代码是:
{createServer} = require 'connect'
{createPool} = require './pool'
我想知道返回值是多少require 'connect'
是什么{}
意思{createServer}
在这个文件中:https ://github.com/josh/nack/blob/master/src/server.coffee
代码是:
{createServer} = require 'connect'
{createPool} = require './pool'
我想知道返回值是多少require 'connect'
是什么{}
意思{createServer}
{} 是 CoffeeScripts 解构赋值。
//file connect.js
...
module.exports = {
createServer: function(){...},
someOtherExport: function() {...},
somethingDifferentAgain: function() {...}
};
然后在您的模块中,您可以只导入 createServer
{createServer} = require "connect"
或者您可以导入连接模块中定义的所有符号
{createServer,
someOtherExport,
SomethingDifferentAgain } = require "connect"
如果您想知道从 connect 导出的内容,您应该简单地对其进行迭代
theModule = require 'connect'
for key, value of theModule
console.log "#{key}: - #{value}"