Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fabientownsend/confeature-flag
A sweet feature flag for JavaScript & TypeScript.
https://github.com/fabientownsend/confeature-flag
feature-flag feature-flags feature-toggle feature-toggles javascr typescript typescript-library
Last synced: 3 months ago
JSON representation
A sweet feature flag for JavaScript & TypeScript.
- Host: GitHub
- URL: https://github.com/fabientownsend/confeature-flag
- Owner: fabientownsend
- Created: 2020-04-22T19:36:58.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T04:48:38.000Z (almost 2 years ago)
- Last Synced: 2024-07-17T17:16:25.019Z (4 months ago)
- Topics: feature-flag, feature-flags, feature-toggle, feature-toggles, javascr, typescript, typescript-library
- Language: TypeScript
- Homepage: https://confeature-flag.now.sh
- Size: 302 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 19
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Confeature Flag 🍯
A sweet feature flag for JavaScript & TypeScript.
**🚀 Easy to use**: Declare the lists of your feature and for which context they are released.
**😻 Fast feedback from users**: By avoiding long-lived Git branches, you can get feedback faster from your users.
**🚦 Flexibility of release**: Be empowered by continuously deploying your code and deciding when/where and for who your features are released.
## Getting Started
**1** - Install Confeature Flag using `yarn`:
`yarn add confeature-flag`
Or `npm`:
`npm install confeature-flag`
**2** - Import the dependency
```javascript
const { newConfeatureFlag } = require("confeature-flag");or
import { newConfeatureFlag } from "confeature-flag";
```**3** - Create the configuration which lists the features and the contexts for which they are released. This will work with a json or JavaScript object.
```javascript
const configuration = `{
"my_super_feature": {
"release_for": ["dev", "qa", "betaTesterUser"]
}
}`;
```**4** - Then create a feature flag that contains the configuration plus the initial context. This will return an object with functions generated based on the list of the features provided.
```javascript
const context = "dev";
const confeatureFlag = newConfeatureFlag(configuration, context);
```**5.a** - The feature `my_super_feature` will generate `isMySuperFeatureReleased()` function and will return its result based on the initial context.
```javascript
if (confeatureFlag.isMySuperFeatureReleased()) {
// path if the feature is released for the initial context
}
```**5.b** - A second function is also generated for each feature which allows you to set a different context on the fly. The feature `my_super_feature` will generated `isMySuperFeareReleasedFor(yourDifferentContext)` and will return its result based on this new context.
```javascript
if (confeatureFlag.isMySuperFeatureReleasedFor("betaTesterUser")) {
// path if the feature is released for a new context
}
```