InstallAdds a few options methods to base, like
option
,enable
anddisable
. See the readme for the full API.
Install with npm:
Usage$ npm install --save base-option
Use as a plugin with with your base
application:
API .optionvar Base = require('base');
var options = require('base-option');
Â
var base = new Base();
base.use(options());Â
Â
app.option('a', 'b');
Â
app.option('x.y', 'z');
Â
console.log(app.option('x'));
Set or get an option.
Params
key
{String}: The option name.value
{any}: The value to set.returns
{any}: Returns a value
when only key
is defined.Example
.hasOptionapp.option('a', true);
app.option('a');
Return true if options.hasOwnProperty(key)
Params
prop
{String}returns
{Boolean}: True if prop
exists.Example
.enableapp.hasOption('a');
app.option('a', 'b');
app.hasOption('a');
Enable key
.
Params
key
{String}returns
{Object} Options
: to enable chainingExample
.disableDisable key
.
Params
key
{String}: The option to disable.returns
{Object} Options
: to enable chainingExample
.enabledCheck if prop
is enabled (truthy).
Params
prop
{String}returns
{Boolean}Example
.disabledapp.enabled('a');
Â
app.enable('a');
app.enabled('a');
Check if prop
is disabled (falsey).
Params
prop
{String}returns
{Boolean}: Returns true if prop
is disabled.Example
.isTrueapp.disabled('a');
Â
app.enable('a');
app.disabled('a');
Returns true if the value of prop
is strictly true
.
Params
prop
{String}returns
{Boolean}: Uses strict equality for comparison.Example
.isFalseapp.option('a', 'b');
app.isTrue('a');
Â
app.option('c', true);
app.isTrue('c');
Â
app.option({a:Â {b:Â {c:Â true}}});
app.isTrue('a.b.c');
Returns true if the value of key
is strictly false
.
Params
prop
{String}returns
{Boolean}: Uses strict equality for comparison.Example
.isBooleanapp.option('a', null);
app.isFalse('a');
Â
app.option('c', false);
app.isFalse('c');
Â
app.option({a:Â {b:Â {c:Â false}}});
app.isFalse('a.b.c');
Return true if the value of key is either true
or false
.
Params
key
{String}returns
{Boolean}: True if true
or false
.Example
.option.setapp.option('a', 'b');
app.isBoolean('a');
Â
app.option('c', true);
app.isBoolean('c');
Set option key
on app.options
with the given value
Params
key
{String}: Option key, dot-notation may be used.value
{any}Example
.option.getapp.option.set('a', 'b');
console.log(app.option.get('a'));
Get option key
from app.options
Params
key
{String}: Option key, dot-notation may be used.returns
{any}Example
.option.createapp.option({a:Â 'b'});
console.log(app.option.get('a'));
Returns a shallow clone of app.options
with all of the options methods, as well as a .merge
method for merging options onto the cloned object.
Params
options
{Options}: Object to merge onto the returned options object.returns
{Object}Example
About Related projectsvar opts = app.option.create();
opts.merge({foo:Â 'bar'});
data
method to base-methods. | homepagePull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Contributors Building docs(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)
To generate the readme, run the following command:
Running tests$ npm install -g verbose/verb#dev verb-generate-readme && verb
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
Author$ npm install && npm test
Jon Schlinkert
LicenseCopyright © 2017, Jon Schlinkert. Released under the MIT License.
This file was generated by verb-generate-readme, v0.6.0, on May 30, 2017.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4