reopt

1.2.0 • Public • Published

reopt

Build status NPM version Downloads Dependency Status

Test coverage

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() {}
}
*/

License

License

Readme

Keywords

Package Sidebar

Install

npm i reopt

Weekly Downloads

234

Version

1.2.0

License

ISC

Last publish

Collaborators

  • ftft1885