options-cache
Simple API for managing options in JavaScript applications.
Last updated 11 years ago by jonschlinkert .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install options-cache 
SYNC missed versions from official npm registry.

options-cache NPM version

Simple API for managing options in JavaScript applications.

Install

Install with npm

npm i options-cache --save

API

Options

Create a new instance of Options.

  • options {Object}: Initialize with default options.

Example:

var util = require('util');
var Options = require('options-cache');

function App(options) {
  Options.call(this, options);
}
util.inherits(App, Options);

App.prototype.a = function(value) {
  this.enable(value);
};

App.prototype.b = function(value) {
  if (this.enabled(value)) {
    // do something
  }
};

.option

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

.enabled

Check if key is enabled (truthy).

  • key {String}
  • returns: {Boolean}
app.enabled('a');
//=> false

app.enable('a');
app.enabled('a');
//=> true

.disabled

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

.enable

Enable key.

  • key {String}
  • returns {Object} Options: to enable chaining

Example

app.enable('a');

.disable

Disable key.

  • key {String}: The option to disable.
  • returns {Object} Options: to enable chaining

Example

app.disable('a');

Author

Jon Schlinkert

License

Copyright (c) 2014 Jon Schlinkert, contributors.
Released under the MIT license


This file was generated by verb-cli on October 11, 2014.

Current Tags

  • 0.3.1                                ...           latest (11 years ago)

7 Versions

  • 0.3.1                                ...           11 years ago
  • 0.3.0                                ...           11 years ago
  • 0.2.1                                ...           12 years ago
  • 0.2.0                                ...           12 years ago
  • 0.1.2                                ...           12 years ago
  • 0.1.1                                ...           12 years ago
  • 0.1.0                                ...           12 years ago
Maintainers (2)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (1)
Dev Dependencies (4)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |