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

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -