# feature-flag

> A feature flag library

Latest version **0.3.0-preview** (published 2015-01-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install feature-flag
pnpm add feature-flag
yarn add feature-flag
bun add feature-flag
```

## 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.3.0-preview |
| Published | 2015-01-24 |
| First published | 2015-01-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+5 in 1 direct dependencies) |
| Install scripts | no |
| Author | Auth0 Inc. |
| Maintainers | ntotten |

## Links

- npm: https://www.npmjs.com/package/feature-flag
- Repository: https://github.com/ntotten/feature-flag
- Issues: https://github.com/ntotten/feature-flag/issues
- npm.io page: https://npm.io/package/feature-flag

## Dependencies (2)

- [lodash](https://npm.io/package/lodash.md) ^2.4.1
- [js-yaml](https://npm.io/package/js-yaml.md) ^3.2.5

## Recent versions

- 0.3.0-preview (latest) — 2015-01-24
- 0.2.0-preview — 2015-01-24
- 0.1.0 — 2015-01-24

## README

# Feature
A feature flag library.

## Key features
* Key Feature 1
* Key Feature 2
* Key Feature 3

## Install
Install this library using npm.

```bash
npm install feature-flag
```

## Usage
How to run the sample or start using the product

In order to get started you simply need to create a ```features.yaml``` file at the root of your project and use the following code.

```js
var feature = require('../index');
feature.load();

if (feature.isEnabled('myfeature')) {
  // Do something
}
```

### Loading Providers
By default, you don't need to worry about configuration providers directly. However, if you want to use a custom provider or if you want to use mulitple providers you can register them as follows. Note, that the order of the providers matters - config settings get loaded in the order the providers were loaded so your last loaded provider can overwrite values from ealier providers.

```js
feature.addProvider(feature.Providers.YamlProvider({ path: './features.yaml' }));
feature.load(); # You must call load after you add the providers
```

## API Reference


Basic usage:
```
feature.isEnabled('feature');

feature.isEnabledForUser('feature', 'jane@example.com');

feature.isEnabledForBucket('feature', 'groups', 'group1');


var world = {
  users: 'jane@example.com',
  groups: ['group1', 'group2']
}
feature.isEnabledFor('feature', world);

```

### Yaml Configuration
Yaml is the default method of configuration. Below you can see enables of different configurations. By default feature looks for a features.yaml file at the root of your application, but you can customize if needed.

```yaml
# Simple Features - always on or off
feature1: on
feature2: off
feature1a: 
  - enabled: on
feature2a: 
  - enabled: off

# Features for specific users
user_feature1:
  users:
    - john@example.com
    - jane@example.com
user_feature2:
  users:
    - id: john@example.com
      enabled: on
    - id: jane@example.com
      enabled: off

# Admin only feature
admin_feature:
  admin: on
```

## Examples
Examples of how to use the sample/product

## Issue Reporting

If you have found a bug or if you have a feature request, please report them at this repository issues section. Please do not report security vulnerabilities on the public GitHub issue tracker. The [Responsible Disclosure Program](https://auth0.com/whitehat) details the procedure for disclosing security issues.

## Author

[Auth0](auth0.com)

## License

This project is licensed under the MIT license. See the [LICENSE](LICENSE.txt) file for more info.

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