javascript - What's an elegant way to export objects in CoffeeScript module? -
i have several functions in coffeescript module:
func1 = () -> ... func2 = () -> ... func3 = () -> ... func4 = () -> ...
if want make clear come (without searching definition), i'd avoid making them global (@func1 = ...
, @func2 = ...
) , , stick more explicit syntax:
helpers = require('/lib/helpers.coffee')
but requires like
meteor.exports.func1 = func1
repeated every time. or
meteor.exports.func1 = () -> ...
but way it's harder make calls between them here inside.
i know es6 has elegant syntax {var1, var2, ...}
, there similar in coffeescript?
func1 = () -> func2 = () -> module.exports = {func1, func2}
compiled to:
var func1, func2; func1 = function() {}; func2 = function() {}; module.exports = { func1: func1, func2: func2 };
Comments
Post a Comment