intraxia/wp-gistpen

View on GitHub
resources/samples/coffeescript

Summary

Maintainability
Test Coverage
grade = (student, period=(if b? then 7 else 6), messages={"A": "Excellent"}) ->
    if student.excellentWork
        "A+"
    else if student.okayStuff
        if student.triedHard then "B" else "B-"
    else
        "C"

square = (x) -> x * x

two = -> 2

math =
    root:   Math.sqrt
    square: square
    cube:   (x) -> x * square x

race = (winner, runners...) ->
    print winner, runners

class Animal extends Being
    constructor: (@name) ->

    move: (meters) ->
        alert @name + " moved #{meters}m."

hi = `function() {
    return [document.title, "Hello JavaScript"].join(": ");
}`

heredoc = """
CoffeeScript subst test #{ 010 + 0xf / 0b10 + "nested string #{ /\n/ }"}
"""

###
CoffeeScript Compiler v1.2.0
Released under the MIT License
###

OPERATOR = /// ^ (
?: [-=]>             # function
) ///