New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ts-feature-flags

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-feature-flags

We use this system to define features that we can easily turn on and off, for testing or to put something temporarily on hold.

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

FEATURE FLAGS

We use this system to define features that we can easily turn on and off, for testing or to put something temporarily on hold.

To define one, add it to the defaults object. The value must be a boolean.

Use it in TypeScript code:

import features from "ts-feature-flags";

function foo() {
if (features.enabled("bar")) {
    doSomething();
 }
}

Use it in TSX:

<div>
 {features.enabled("bar") && <Something />}
</div>

Use it in JavaScript code:

import features from "ts-feature-flags";

function foo() {
if (features.bar)) {
    doSomething();
 }
}

To set or unset them, open devtools, and:

features.foo = true;
features.bar = false;
features.unset('piyo'); // resets to default

Then you have to reload the page or restart the app. Intentionally the values are not changed on the fly, to avoid bugs with IPC, React update headaches, etc.

FAQs

Package last updated on 22 Feb 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc