0.0.6 • Published 11 years ago

coffee-pattern v0.0.6

Weekly downloads
11
License
-
Repository
github
Last release
11 years ago

coffee-pattern: use pattern matching like syntax in CoffeeScript

Usage

We don't have pattern matching in CoffeeScript, poor language...

Install from NPM and use in CoffeeScript code:

npm install --save coffee-pattern
{match} = require 'coffee-pattern'

match 'string or number here'
  /^head/, (data) -> print "#{data} matches head"
  /tail$/, (data) -> print "#{data} matches tail"
  5, (data) -> print 'it is five'
  null, (data) -> print "#{data} has no matching pattern"

License

MIT