
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
option-cache
Advanced tools
Simple API for managing options in JavaScript applications.
npm i option-cache --save
Create a new instance of Options
.
options
{Object}: Initialize with default options.var options = new Options();
Set or get an option.
key
{String}: The option name.value
{*}: The value to set.returns
{*}: Returns a value
when only key
is defined.app.option('a', true);
app.option('a');
//=> true
Enable key
.
key
{String}returns
{Object} Options
: to enable chainingExample
app.enable('a');
Disable key
.
key
{String}: The option to disable.returns
{Object} Options
: to enable chainingExample
app.disable('a');
Check if key
is enabled (truthy).
key
{String}returns
: {Boolean}app.enabled('a');
//=> false
app.enable('a');
app.enabled('a');
//=> true
Check if key
is disabled (falsey).
key
{String}returns
{Boolean}: Returns true if key
is disabled.app.disabled('a');
//=> true
app.enable('a');
app.disabled('a');
//=> false
Return true if options.hasOwnProperty(key)
key
{String}returns
{Boolean}: True if key
is is on options.app.hasOption('a');
//=> false
app.option('a', 'b');
app.hasOption('a');
//=> true
Return true if options.hasOwnProperty(key)
key
{String}returns
{Boolean}: True if key
is is on options.app.hasOption('a');
//=> false
app.option('a', 'b');
app.hasOption('a');
//=> true
keys
{Array}returns
: {Array}Generate an array of command line args from
the given keys
or all options.
Use options-cache in your javascript application:
var util = require('util');
var Options = require('options-cache');
function App(options) {
Options.call(this, options);
this.init();
}
util.inherits(App, Options);
App.prototype.init = function() {
this.option('cwd', process.cwd());
this.option('foo', 'bar');
};
App.prototype.a = function(value) {
this.enable(value);
};
App.prototype.b = function(value) {
if (this.enabled(value)) {
// do something
} else {
// do something else
}
};
Jon Schlinkert
Copyright (c) 2015 Jon Schlinkert
Released under the MIT license
This file was generated by verb on February 13, 2015.
FAQs
Simple API for managing options in JavaScript applications.
The npm package option-cache receives a total of 27,699 weekly downloads. As such, option-cache popularity was classified as popular.
We found that option-cache demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.