Socket
Socket
Sign inDemoInstall

overloader

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    overloader

function overloading


Version published
Weekly downloads
1
Maintainers
1
Install size
5.32 kB
Created
Weekly downloads
 

Readme

Source

overloader

node.js function overloading

install

$ npm install overloader

overloader gives you the ability to overload your functions

to start create an overloaded environment:

var Overloader = require('overloader');

var overloaded = new Overloader();

overloaded.overload(function() {
    return 'no arguments';
});

overloaded.overload('number', function(num) {
	return 'there was a number: ' + num;
});

overloaded.overload('string', 'number', function(name, num) {
	return 'there was a number: ' + num + ' with the name ' + name;
});

declare your function and pass this and arguments to the .load() function of your environment:

function myFunction() {
	return overloaded.load(this, arguments);
}

now you can call your function as usual:

console.log(myFunction());
console.log(myFunction(5));
console.log(myFunction('Fabio Poloni', 9));

the output will be:

no arguments
there was a number: 5
there was a number: 9 with the name Fabio Poloni

Keywords

FAQs

Last updated on 16 Jan 2014

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc