Skip to content

jsdevel/node-overloading

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

overloading

Define complex overloads for functions! Errors are thrown if no matching overload is found.

##Example

var overloading = require('overloading');
var fooOverloads = overloading([
  [Function],
  [String, String]
]); 

function foo(one, two){
  switch(fooOverloads.find(arguments)){
    case 0:one();break;
    case 1:console.log(one + ' ' + two);break;
  }
}

foo('hello', 'world!');
//prints "hello world!"
foo(foo.bind(null, 'say', 'what?'));
//prints "say what?"

About

Define complex overloading strategies for functions.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published