Skip to content

Checks requirements for and adds defaults to parameter objects

License

Notifications You must be signed in to change notification settings

matteckert/optcheck

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Checks requirements for and adds defaults to parameter objects

Resources

License

Stars

Watchers

Forks

Packages

No packages published