# confab-features

> Runtime feature gating for confab applications

Latest version **0.0.2** (published 2016-06-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install confab-features
pnpm add confab-features
yarn add confab-features
bun add confab-features
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2016-06-11 |
| First published | 2015-12-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | RJ Zaworski |
| Maintainers | rjz |
| Keywords | confab, config, features |

## Links

- npm: https://www.npmjs.com/package/confab-features
- Repository: https://github.com/rjz/confab-features
- Issues: https://github.com/rjz/confab-features/issues
- npm.io page: https://npm.io/package/confab-features

## Dependencies (2)

- [confab](https://npm.io/package/confab.md) ~0.0.9
- [object-assign](https://npm.io/package/object-assign.md) ~4.0.1

## Recent versions

- 0.0.2 (latest) — 2016-06-11
- 0.0.1 — 2015-12-08

## README

confab-features
===============================================================================

[![Build
Status](https://travis-ci.org/rjz/confab-features.svg?branch=master)](https://travis-ci.org/rjz/confab-features)
[![Coverage
Status](https://coveralls.io/repos/rjz/confab-features/badge.svg?branch=master)](https://coveralls.io/r/rjz/confab-features?branch=master)

Feature gates for [confab][confab]. Declare a list of features that can be
toggled on and off:

```js
var confab = require('confab');
var features = require('confab-features');

var config = confab([
  features([
    'new_ui'
  ])
]);
```

Run the app with gates set by either a previous transformation or environment
overrides:

```sh
$ CONFIG_FEATURES_NEW_UI=true \
  node app.js
```

Then, inside the app, retrieve the feature configurations from a processed
confab `config`:

```js
if (config.features.new_ui) {
  renderNewUi();
}
else {
  renderLegacyUi();
}
```

The full list of configured features is available by invoking `config.features`
directly:

```js
config.features().forEach(function (feature) {
  console.log(feature.key, feature.description);
});
```

API
-------------------------------------------------------------------------------

`confab-features` exports:

```js
features(items: Array<Object|String>, opts: Map<String, any>): Map<String, Boolean>
```

Note that `items` may contain both string `keys` and simple object with a `key`
and (optional) description of the feature:

```
[
  'new_ui',
  { key: 'new_campaign', description: 'A switch to flip' }
]
```

#### opts

Name        | Type      | Description
----------- | --------- | --------------------------------
`configKey` | `String`  | The `config` key for `'features'` and environment variables (default: `'features'`)
`validate`  | `Boolean` | Throw on undeclared or invalid feature settings (default: `true`)

> Quis configiet ipsos configes?

Development
-------------------------------------------------------------------------------

Clone this repository:

    $ git clone git@github.com:rjz/confab-features.git

...and copy, fork, customize, and whatever you need to do.

Testing
-------------------------------------------------------------------------------

Lint and run test suite:

    $ npm test

License
-------------------------------------------------------------------------------

MIT

[confab]: https://github.com/rjz/confab

---
_Source: https://npm.io/package/confab-features · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
