reopt
v1.2.0
Published
get options from arguments with multiple overloads
Downloads
883
Readme
reopt
[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][downloads-url] [![Dependency Status][david-image]][david-url] [npm-image]: https://img.shields.io/npm/v/reopt.svg?style=flat-square [npm-url]: https://npmjs.org/package/reopt [downloads-image]: http://img.shields.io/npm/dm/reopt.svg?style=flat-square [downloads-url]: https://npmjs.org/package/reopt [david-image]: http://img.shields.io/david/chunpu/reopt.svg?style=flat-square [david-url]: https://david-dm.org/chunpu/reopt
get options from arguments with multiple overloads
Installation
npm i reopt
Api
new Reopt(typeDefine, templates)
e.g.
new Reopt({
param1: 'type1 type2'
param2: 'type3'
}, ['param1', 'param1 param2'])
Usage
var Reopt = require('reopt')
var reopt = new Reopt({
url: 'string',
opt: 'object',
callback: 'function'
}, [
'url callback',
'url',
'opt callback',
'opt'
])
function request() {
var opt = reopt.get(arguments)
console.log(opt)
}
request('http://some.server.com/', function() {})
/*
=> {
url: 'http://some.server.com/',
callback: function() {}
}
*/