Skip to content

Instantly share code, notes, and snippets.

@rolandovillca
Last active August 29, 2015 14:17
Show Gist options
  • Save rolandovillca/c2f446a5296e45f62eea to your computer and use it in GitHub Desktop.
Save rolandovillca/c2f446a5296e45f62eea to your computer and use it in GitHub Desktop.
COFFEESCRIPT NOTES
###
$ sudo npm install -g coffee-script
###
# COMPARING TERNARY CODE:
@getInstance: ->
Instante ?= new DeviceManager()
DeviceManagerSingleton.getInstance = function() {
return Instante != null ? Instante : Instante = new DeviceManager();
};
# HOW TO EXPORT MODULES:
# Example 1:
# module.coffee
class Module
construct: (@name) ->
module.exports = Module
# index.coffee
Module = require './module'
instance = new Module
# Example 2:
# hello.coffee
module.exports = class Hello
greet: () ->
console.log 'hello'
# app.coffee
Hello = require("#{__dirname}/hello")
hello = new Hello()
hello.greet()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment