options-cache 
Get and set options easily, for node.js projects.
Install
Install with npm:
npm i options-cache --save-dev
API
Options
Initialize a new Options cache.
options {Object}: Initialize with default options.
Example:
In your application:
var util = require('util');
var Options = require('options-cache');
function App(options) {
Options.call(this, options);
}
util.inherits(App, Options);
App.prototype.foo = function(value) {
this.enable(value);
};
App.prototype.bar = function(value) {
if (this.enabled(value)) {
}
};
option
Set or get an option.
key {String}
value {*}
- returns {Object}
Options: to enable chaining
app.option('a', true)
app.option('a')
set
Assign value to key or return the value of key.
key {String}
value {*}: The value to set.
- returns {Object}
Options: to enable chaining
app.set('foo', true)
get
Return the stored value of key.
app.set('foo', true)
app.get('foo')
extend
Extend the options with the given object. This method is chainable.
- returns {Cache}: for chaining
Example
options
.extend({foo: 'bar'}, {baz: 'quux'});
.extend({fez: 'bang'});
Or define the property to extend:
options
.extend('a', {foo: 'bar'}, {baz: 'quux'})
.extend('b', {fez: 'bang'})
.extend('a.b.c', {fez: 'bang'});
enabled
Check if key is enabled (truthy).
key {String}
- returns: {Boolean}
app.enabled('foo')
app.enable('foo')
app.enabled('foo')
disabled
Check if key is disabled (falsey).
key {String}
- returns {Boolean}: Returns true if
key is disabled.
app.disabled('foo')
app.enable('foo')
app.disabled('foo')
enable
Enable key.
key {String}
- returns {Object}
Options: to enable chaining
Example
app.enable('foo')
disable
Disable key.
key {String}: The option to disable.
- returns {Object}
Options: to enable chaining
Example
app.disable('foo')
clear
Remove key from the cache, or if no value is specified the entire options is reset.
Example:
options.clear();
Author
Jon Schlinkert
License
Copyright (c) 2014 Jon Schlinkert, contributors.
Released under the MIT license
This file was generated by verb-cli on August 09, 2014.