feature-flag

0.3.0-preview • Public • Published

Feature

A feature flag library.

Key features

  • Key Feature 1
  • Key Feature 2
  • Key Feature 3

Install

Install this library using npm.

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.

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.

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.

# 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 details the procedure for disclosing security issues.

Author

Auth0

License

This project is licensed under the MIT license. See the LICENSE file for more info.

Readme

Keywords

none

Package Sidebar

Install

npm i feature-flag

Weekly Downloads

20

Version

0.3.0-preview

License

MIT

Last publish

Collaborators

  • ntotten