Last active
August 29, 2015 14:17
-
-
Save rolandovillca/c2f446a5296e45f62eea to your computer and use it in GitHub Desktop.
COFFEESCRIPT NOTES
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### | |
$ 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