1.0.3 • Published 10 years ago
epic.optargs v1.0.3
epic.optargs
js optional args
Installation
$ npm install epic.optargsConfig
{
name:'', // string
index:0, // number
optional:true, // bool
type:'', // string & array
value:'' // object, default value
}type alias
{
'bool': 'boolean',
'class': 'object',
'Class': 'object',
'func': 'function',
'fn': 'function',
'int': 'Number'
}Usage
var args = require('epic.optargs');// default config
// _ : {optional: true}
// [fn, callback] : {type: 'function'}
var test = function(_obj, id, _fn){ console.log(arguments); };
args(test)('id');// comment config
// inline
var test = function(_obj /* {type:'object'} */, id /* {type:'string'} */, _fn){ console.log(arguments); };
// multi
var test = function(
_obj, // {type:'object'}
id, // {type:'string'}
_fn
)
{
console.log(arguments);
};
// or
var test = function(
_obj // {type:'object'}
,id // {type:'string'}
,_fn
)
{
console.log(arguments);
};// runtime config
var test = function(_obj, id, _fn){ console.log(arguments); };
args(test, {name:'id', value:'id'}, {index:0, value:{}});Contributors
Author: S
License
MIT