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
# settings file | |
development: | |
gateway: test | |
test: | |
gateway: jira | |
production: | |
gateway: jira |
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
# a type representing a number, that can be mapped to a fizzbuzz output | |
class Value | |
constructor: (@number) -> | |
# calculate the correct output for the value of @number | |
map: () -> | |
if @_is_fizzbuzz() | |
return 'fizzbuzz' | |
if @_is_fizz() | |
return 'fizz' |
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
// from http://wiki.ecmascript.org/doku.php?id=strawman:arrow_function_syntax | |
// Empty arrow function is minimal-length | |
let empty = ->; | |
let square = (x) -> x * x; |
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
// from http://wiki.ecmascript.org/doku.php?id=strawman:block_lambda_revival | |
let empty = {||}; | |
let square = {|x| x * x}; |
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
alert = (message) -> | |
console.log message | |
language = "CoffeeScript" | |
message = "Hello #{language}" | |
output = (comment) -> | |
alert comment |
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
Object.prototype._properties = () -> | |
properties = ("#{key}=#{value}" for key,value of this when typeof value isnt 'function') |
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
Object.prototype._properties = function() { | |
var properties = []; | |
for (p in this) { | |
if (typeof this[p] !== 'function') { | |
properties.push(p + "=" + this[p]); | |
} | |
} | |
return properties; | |
} |
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
a.coffee | |
define(['dep'], (dep) -> | |
(d) -> | |
d = d || dep | |
{ } | |
) |
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
// I'm calling this an anti-pattern because you cannot test this module | |
// without also testing the 'fs' module or monkey patching the require function. | |
var fs = require('fs'); | |
exports.myObject = { | |
action: function() { | |
return fs.read('foo'); | |
} |
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
// Module A.js | |
exports = function(dep1, dep2) { | |
dep1 = dep1 || require('dep1'); | |
dep2 = dep2 || require('dep2'); | |
return { | |
action: function() { | |
return dep1.foo() + dep2.bar(); |