Translating functions from JavaScript to CoffeeScript