0.4.0 • Published 3 years ago

@feature-flip/feature-flip-js v0.4.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

✨ Features:

  • Local feature flag management
  • Undefined feature failover

🔧 Installation

npm i @feature-flip/feature-flip-js

🌐 Basic usage

import FeatureFlipJS, { FeatureFlag } from '@feature-flip/feature-flip-js';

const features: FeatureFlag[] = [
  {
    id: '1234',
    slug: 'my-feature-1234',
    name: 'my-feature',
    enabled: !isProduction,
    description: 'My feature',
  },
]

const featureFlags = new FeatureFlipJS({ features });

const { enabled: myFeatureEnabled } = featureFlags.getFeatureByName('my-feature');

if (myFeatureEnabled) {
  ...
}

❗Failover

Accessing a feature that is not defined will return a null FeatureFlag with enabled: false

const { enabled: failFeatureEnabled } = featureFlags.getFeatureByName('fail');
// enabled will be false

💂‍♂️ Accessors

// Returns the feature flags as an object
// where the feature flag name is the object key
featureFlags.getFeaturesMap();

// Access by the id property
featureFlags.getFeatureById('1234');

// Access by the slug property
featureFlags.getFeatureBySlug('my-feature-1234');

// Access by the name property
featureFlags.getFeatureByName('my-feature');
0.4.0

3 years ago

0.3.0

3 years ago

0.2.0

3 years ago

0.1.0

3 years ago