I have the following javascript:
Function.prototype.debounce = function (threshold, execAsap) {
var func = this, timeout;
return function debounced () {
//body
}
};
How can I return a named function like this in coffeescript?
You can't name functions in Coffeescript. The reason is given in the FAQ -- grep for "Is there any way to name functions, for reflection and recursion?" If you really need to embed a name, you could use backticks to embed raw Javascript.