is-enabled
Using key paths that may contain "falsey" patterns, check if a property on an object is enabled.
Last updated 5 years ago by doowb .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install is-enabled 
SYNC missed versions from official npm registry.

is-enabled NPM version Build Status

Using key paths that may contain "falsey" patterns, check if a property on an object is enabled.

Install

Install with npm:

$ npm i is-enabled --save

Usage

Require in the is-enabled function and setup an object to use.

var isEnabled = require('is-enabled');
var options = {};

Check if the verbose property is enabled. Returns true when verbose is true.

options.verbose = true;
console.log(isEnabled(options, 'verbose'));
//=> true

Returns false when verbose is false.

options.verbose = false;
console.log(isEnabled(options, 'verbose'));
//=> false

Use "falsey" patterns in the key path to toggle the results.

Returns false when verbose is true.

options.verbose = true;
console.log(isEnabled(options, 'not.verbose'));
//=> false

Returns true when verbose is false.

options.verbose = false;
console.log(isEnabled(options, 'not.verbose'));
//=> true

Related projects

falsey: Returns true if value is falsey. Works for strings, arrays and arguments objects with a… more | homepage

Generate docs

Generate readme and API documentation with [verb][]:

$ npm i -d && npm run docs

Or, if [verb][] is installed globally:

$ verb

Running tests

Install dev dependencies:

$ npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Author

Brian Woodward

License

Copyright © 2016 Brian Woodward Released under the MIT license.


This file was generated by verb, v0.1.0, on February 20, 2016.

Current Tags

  • 0.1.0                                ...           latest (5 years ago)

1 Versions

  • 0.1.0                                ...           5 years ago
Maintainers (2)
Downloads
Today 0
This Week 0
This Month 9
Last Day 0
Last Week 3
Last Month 21
Dependencies (3)
Dev Dependencies (7)

Copyright 2014 - 2017 © taobao.org |