mixedargs

1.0.4 • Public • Published

MixedArgs

This is a simple tool for creating function that accepts multiple combination of arguments. This can be used in NodeJS or browser.

Installation

NodeJS:

$ npm install mixedargs --save

Browser:

$ bower install mixedargs --save

Usage

//In node only
var mixedargs = require('mixedargs');
 
var showError = function() {
 
    var args = mixedargs(arguments);
 
    if( args.when(['String', 'Number']) ) {
        //Message, ErrorCode
    }
    else if( args.when(['String', 'String']) ) {
        //Message, ErrorType
    }
}

And async mode

var showError = function() {
 
    var args = mixedargs(arguments);
 
    args.when(['String','Number'], function(message, code){
        //do something
    });
 
    args.when(['String','Object'], function(message, data){
        //do something
    });
 
}

Package Sidebar

Install

npm i mixedargs

Weekly Downloads

0

Version

1.0.4

License

MIT

Last publish

Collaborators

  • albulescu