overloading

1.0.4 • Public • Published

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?"

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.4
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.4
    1
  • 1.0.3
    1
  • 1.0.2
    1
  • 1.0.1
    1
  • 1.0.0
    1

Package Sidebar

Install

npm i overloading

Weekly Downloads

5

Version

1.0.4

License

MIT

Last publish

Collaborators

  • jsdevel