Adds a few options methods to base-methods, like
option
,enable
anddisable
. See the readme for the full API.
Install
Install with npm:
$ npm i base-options --save
Usage
Use as a plugin with with your base
application:
var Base = ;var options = ; var base = ;base; // plugin // set an optionapp; // set a nested propertyapp; // get an optionconsole;//=> {y: 'z'}
API
.option
Set or get an option.
Params
key
{String}: The option name.value
{*}: The value to set.returns
{*}: Returns avalue
when onlykey
is defined.
Example
app;app;//=> true
.hasOption
Return true if options.hasOwnProperty(key)
Params
prop
{String}returns
{Boolean}: True ifprop
exists.
Example
app;//=> falseapp;app;//=> true
.enable
Enable key
.
Params
key
{String}returns
{Object}Options
: to enable chaining
Example
app;
.disable
Disable key
.
Params
key
{String}: The option to disable.returns
{Object}Options
: to enable chaining
Example
app;
.enabled
Check if prop
is enabled (truthy).
Params
prop
{String}returns
{Boolean}
Example
app;//=> false app;app;//=> true
.disabled
Check if prop
is disabled (falsey).
Params
prop
{String}returns
{Boolean}: Returns true ifprop
is disabled.
Example
appdisabled'a';//=> true app;appdisabled'a';//=> false
.isTrue
Returns true if the value of prop
is strictly true
.
Params
prop
{String}returns
{Boolean}: Uses strict equality for comparison.
Example
app;app;//=> false app;app;//=> true app;app;//=> true
.isFalse
Returns true if the value of key
is strictly false
.
Params
prop
{String}returns
{Boolean}: Uses strict equality for comparison.
Example
app;app;//=> false app;app;//=> true app;app;//=> true
.isBoolean
Return true if the value of key is either true
or false
.
Params
key
{String}returns
{Boolean}: True iftrue
orfalse
.
Example
app;app;//=> false app;app;//=> true
Related projects
- base-data: adds a
data
method to base-methods. | homepage - base-methods: base-methods is the foundation for creating modular, unit testable and highly pluggable node.js applications, starting… more | homepage
- class-utils: Utils for working with JavaScript classes and prototype methods. | homepage
Running tests
Install dev dependencies:
$ npm i -d && npm test
Coverage
As of January 19, 2016
Statements : 100% Branches : 100% Functions : 100% Lines : 100%
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Author
Jon Schlinkert
License
Copyright © 2016 Jon Schlinkert Released under the MIT license.
This file was generated by verb on January 19, 2016.