# confeature-flag

> Sweet feature flag for JavaScript & TypeScript.

Latest version **1.1.2** (published 2020-08-13) · ISC license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2020-08-13 |
| First published | 2020-04-25 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Fabien Townsend |
| Maintainers | fabientownsend |
| Keywords | feature flag, front-end, back-end, continuous delivery, web |

## Links

- npm: https://www.npmjs.com/package/confeature-flag
- Repository: https://github.com/fabientownsend/confeature-flag
- Homepage: https://github.com/fabientownsend/confeature-flag#readme
- Issues: https://github.com/fabientownsend/confeature-flag/issues
- npm.io page: https://npm.io/package/confeature-flag

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 1.1.2 (latest) — 2020-08-13
- 1.1.0 — 2020-04-28
- 1.0.0 — 2020-04-25

## README

<h1 align="center">Confeature Flag 🍯</h1>

<h2 align="center">A sweet feature flag for JavaScript & TypeScript.</h2>

**🚀 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
}
```

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