How to generate global, named javascript functions in coffeescript, for Google Apps Script

前端 未结 4 877
自闭症患者
自闭症患者 2020-12-20 15:39

I\'d like to write Javascript scripts for Google Apps Script using CoffeeScript, and I\'m having trouble generating functions in the expected form.

Google Apps Scrip

4条回答
  •  孤城傲影
    2020-12-20 15:52

    This should give you a global named function (yes, it's a little hacky, but far less that using backticks):

    # wrap in a self invoking function to capture global context
    do ->
      # use a class to create named function
      class @triggerableFunction
        # the constructor is invoked at instantiation, this should be the function body
        constructor: (arg1, arg2) ->
          # whatever
    

提交回复
热议问题