Socket
Socket
Sign inDemoInstall

unleash-client

Package Overview
Dependencies
Maintainers
3
Versions
116
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unleash-client

Unleash Client for Node


Version published
Weekly downloads
227K
increased by7.06%
Maintainers
3
Weekly downloads
 
Created

What is unleash-client?

The unleash-client npm package is a feature toggle system that allows you to control the release of features in your application. It helps you manage feature flags, enabling or disabling features without deploying new code.

What are unleash-client's main functionalities?

Initialize Unleash Client

This code initializes the Unleash client with the necessary configuration, including the URL of the Unleash server, the application name, and the instance ID.

const { UnleashClient } = require('unleash-client');

const unleash = new UnleashClient({
  url: 'http://unleash.herokuapp.com/api/',
  appName: 'my-app',
  instanceId: 'my-instance-id',
});
unleash.start();

Check if a feature is enabled

This code checks if a specific feature toggle (in this case, 'someFeature') is enabled and logs the result.

const isEnabled = unleash.isEnabled('someFeature');
console.log(`Feature is enabled: ${isEnabled}`);

Register custom strategies

This code demonstrates how to register a custom strategy with the Unleash client. Custom strategies allow you to define your own logic for enabling or disabling features.

unleash.on('ready', () => {
  unleash.registerStrategy(new CustomStrategy());
});

class CustomStrategy {
  constructor() {
    this.name = 'custom';
  }

  isEnabled(parameters, context) {
    // Custom logic to determine if the feature is enabled
    return true;
  }
}

Other packages similar to unleash-client

Keywords

FAQs

Package last updated on 11 Mar 2024

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