0.1.5 • Published 6 months ago

feature-toggle-package v0.1.5

Weekly downloads
-
License
ISC
Repository
-
Last release
6 months ago

Feature Toggle Package

A lightweight and flexible feature toggle (feature flag) implementation for JavaScript/TypeScript applications.

Installation

npm install feature-toggle-package

Features

  • Hierarchical configuration with modules, submodules, and features
  • TypeScript support with full type definitions
  • Zero dependencies
  • Simple and intuitive API

Usage

import { FeatureToggle, AppConfig } from 'feature-toggle-package';

const config: AppConfig = {
  modules: {
    authentication: {
      enabled: true,
      submodules: {
        social: {
          enabled: true,
          features: {
            googleLogin: true,
            facebookLogin: false
          }
        }
      }
    }
  }
};

const featureToggle = new FeatureToggle(config);

// Check if a module is enabled
const isAuthEnabled = featureToggle.isFeatureEnabled('authentication');

// Check if a submodule is enabled
const isSocialEnabled = featureToggle.isFeatureEnabled('authentication', 'social');

// Check if a specific feature is enabled
const isGoogleLoginEnabled = featureToggle.isFeatureEnabled('authentication', 'social', 'googleLogin');

Configuration Structure

interface AppConfig {
  modules: {
    [moduleName: string]: {
      enabled: boolean;
      submodules?: {
        [submoduleName: string]: {
          enabled: boolean;
          features?: {
            [featureName: string]: boolean;
          };
        };
      };
    };
  };
}

License

ISC

0.1.2

6 months ago

0.1.4

6 months ago

0.1.3

6 months ago

0.1.5

6 months ago

0.1.1

6 months ago