optcheck
v1.0.1
Published
Checks requirements for and adds defaults to parameter objects
Downloads
5
Maintainers
Readme
optcheck
Checks requirements for and adds defaults to parameter objects
var optcheck = require('optcheck');
var args = {async: false, type: 'json'};
optcheck(args)
.defaults({
async: true,
url: 'http://localhost'
})
.requires('type', 'url');
args.should.eql({async: false, type: 'json', url: 'http://localhost'});
API
optcheck({})
Takes a parameter object.
Returns an optcheck
object to operate on the parameter object passed in.
.requires()
Checks the parameter object for properties.
Returns this
.
.defaults({})
Adds properties from object
to the parameter object if the parameter object needs the property.
Returns this
.