@kablamo/kerosene-feature-flags
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Kerosene Feature Flags

A simple assertion style feature flag for use in CI/CD deployment pipelines, especially well suited to monorepos and Trunk Based Development.

Feature Flags give you the ability to safely enable features in different environments, and for specific cohorts of people.

yarn add @kablamo/kerosene-feature-flags

Getting Started

With a Kerosene Feature Flag you define a flag as an assertion of conditions, and their expected values.

import { flag } from "@kablamo/kerosene-feature-flags";

const flags = {
    FEATURE123: flag(c => [
        c.condition("environment").must.be.any.of(["development", "staging"]),
        c.condition("group").must.be.exactly("users"),
    ]),
    FEATURE42: flag(c => [
        c.condition("environment").must.be.exactly("production"),
        c.condition("group").must.be.exactly("beta"),
    ]),
};

export { flags };

When you want to use the flags in your application, you import them, and execute them as a function, passing in an object with runtime information.

import { flags } from "./features";

const runtime = {
    environment: "production",
    group: "users",
    browser: "Firefox",
};

if (flags.FEATURE123(runtime)) {
    console.log("New feature");
} else {
    console.log("Old feature");
}
// output:
// New feature

if (flags.FEATURE42(runtime)) {
    console.log("New feature");
} else {
    console.log("Old feature");
}
// output:
// Old feature

Package Sidebar

Install

npm i @kablamo/kerosene-feature-flags

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

27.8 kB

Total Files

15

Last publish

Collaborators

  • kablamo-deployments
  • ojkelly
  • glie163
  • walesey
  • nhardy
  • brycehanscomb