Skip to content

yornaath/func-match

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

funcmatch

Pattern matching. Create typed functions.

Installation

$ component install gorillatron/funcmatch

Usage

var match = require( 'funcmatch' )

var concat = match([String, String], function( a, b ){
                     return a + b
                   },
                   [String, Number], function( a, b ) {
                     return a + '::' + b
                   })

concat( 'foo', 'bar' )
// -> 'foobar'

concat( 'foo', 13 )
// -> 'foo::13

wildcard

var __ = match.__

var foo = match([String, __], 'string *',
                [__, Number], '* number')

foo('bar', {})
// -> 'string *'

foo(false, 42)
// -> '* number'

License

MIT licensed

About

Pattern matching

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published