1.0.1 • Published 4 years ago
optons v1.0.1
optons
optons helps to quickly get options based on your defaults and the users given options.
setup
setting up optons is as easy as installing it through npm and requiring it within your nodejs project
npm i optons
const optons = require("optons");
and that's all you need to setup optons for use in your projects.
optons(defaults: {}, given: {}): {}
the optons
function takes in two arguments
defaults
- the object containing all your default optionsgiven
- the object containing options created by the user
here is an example of how the optons
function is used, along with what the returned object looks like
// create a test function
function print(string, options={}) {
// get options
options = optons(
// default options
{newline: true},
// options given by user
options
);
// check if newline option is true and add newline
if(options.newline) string += "/n";
// write string
process.stdout.write(string);
}
licence
MIT