npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

manage-flags-eazy

v1.0.0

Published

A lightweight and type-safe feature flag management library for JavaScript/TypeScript

Readme

manage-flags-eazy

A lightweight and type-safe feature flag management library for JavaScript/TypeScript applications.

Features

  • 🎯 Simple and intuitive API
  • 📦 TypeScript support out of the box
  • 🔄 Runtime flag updates
  • 👂 Subscribe to flag changes
  • 🔙 Reset to default values
  • 🎭 Zero dependencies
  • 📦 ESM and CommonJS support
  • 🌐 Load flags from JS/TS files or API
  • 🔍 Support for both simple and structured flag formats

Installation

Using npm:

npm install manage-flags-eazy

Using yarn:

yarn add manage-flags-eazy

Using pnpm:

pnpm add manage-flags-eazy

Usage

Basic Usage with Direct Import

The simplest way to use feature flags is to define them in a JavaScript file and import them directly:

// features.js
module.exports = [
  { name: "darkMode", value: true },
  { name: "newFeatures", value: false },
  { name: "betaTesting", value: true }
];
// app.js
const { FeatureFlags } = require('manage-flags-eazy');
const featureFlags = require('./features.js');

// Initialize with the imported flags
const flags = new FeatureFlags(featureFlags);

// Check if a flag is enabled
if (flags.isEnabled('darkMode')) {
  // Enable dark mode
}

// Toggle flags at runtime
flags.enable('newFeatures');
flags.disable('darkMode');

TypeScript Usage

import { FeatureFlags } from 'manage-flags-eazy';
import type { FlagEntry } from 'manage-flags-eazy';

// Import flags dynamically from a JS file
async function loadFlags(): Promise<FlagEntry[]> {
  const flags = await import('./features.js');
  return flags.default || flags;
}

async function setupApp() {
  const featureFlags = await loadFlags();
  const flags = new FeatureFlags(featureFlags);
  
  if (flags.isEnabled('darkMode')) {
    // Dark mode is enabled
  }
}

Loading Flags from API

You can also load flags from an API endpoint:

import { FeatureFlags, APIFlagSource } from 'manage-flags-eazy';

const flags = new FeatureFlags();

// Create an API source
const apiSource = new APIFlagSource('https://api.example.com/feature-flags', {
  headers: {
    'Authorization': 'Bearer your-token-here'
  }
});

// Load flags from the API and merge with existing flags
await flags.loadFrom(apiSource, { 
  merge: true,
  updateDefaults: true
});

// Now use the flags loaded from the API
if (flags.isEnabled('darkMode')) {
  // Dark mode is enabled from API settings
}

The API can return flags in either format:

  • Simple object: { "darkMode": true, "newFeature": false }
  • Structured array: [{ name: "darkMode", value: true }, ...]

Flag Formats

This library supports two formats for feature flags:

Simple Format (Object)

{
  darkMode: true,
  newFeatures: false,
  betaTesting: true
}

Structured Format (Array of Objects)

[
  { name: "darkMode", value: true },
  { name: "newFeatures", value: false },
  { name: "betaTesting", value: true }
]

Subscribing to Changes

const unsubscribe = flags.subscribe((flagName, value) => {
  console.log(`Flag ${flagName} changed to ${value}`);
});

// Later, when you want to stop listening
unsubscribe();

Resetting Flags

// Reset all flags to their initial values
flags.reset();

Getting All Flags

const allFlags = flags.getAllFlags();
console.log(allFlags);

API Reference

FeatureFlags

Constructor

constructor(initialFlags: Record<string, boolean> | Array<{name: string, value: boolean}> = {})

Creates a new instance with optional initial flag values in either simple or structured format.

Methods

  • isEnabled(flagName: string): boolean

    • Check if a feature flag is enabled
  • enable(flagName: string): void

    • Enable a feature flag
  • disable(flagName: string): void

    • Disable a feature flag
  • setFlag(flagName: string, value: boolean): void

    • Set a feature flag's value
  • reset(): void

    • Reset all flags to their default values
  • subscribe(callback: (flagName: string, value: boolean) => void): () => void

    • Subscribe to flag changes
    • Returns an unsubscribe function
  • getAllFlags(): Record<string, boolean>

    • Get all current flag values
  • loadFrom(source: FlagSource, options?: FlagLoadOptions): Promise<void>

    • Load flags from a source (API or JS/TS file)
    • Options:
      • merge: Whether to merge with existing flags (default: true)
      • updateDefaults: Whether to update default values (default: false)

APIFlagSource

constructor(url: string, options?: RequestInit)

Creates a source that loads flags from an API endpoint.

License

MIT