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

@weaverslab/feature-flags

v1.0.1

Published

Feature flags for CodeWeavers

Readme

@weaverslab/feature-flags

A robust feature flag management service for CodeWeavers applications. This library provides a simple and efficient way to manage feature flags in your application with PostgreSQL support and real-time updates.

Features

  • 🚀 Real-time feature flag updates using PostgreSQL notifications
  • 💾 LRU caching for improved performance
  • 🔄 Event-based updates for seamless flag changes
  • 📦 TypeScript support
  • 🔒 Type-safe API

Installation

npm install @weaverslab/feature-flags
# or
yarn add @weaverslab/feature-flags
# or
pnpm add @weaverslab/feature-flags

Prerequisites

  • PostgreSQL database
  • Node.js 14 or higher
  • TypeScript (for TypeScript projects)

Configuration

  1. Set up your environment variables:

    DATABASE_URL=postgresql://user:password@localhost:5432/database
  2. Create the required database table:

    CREATE TABLE hub_feature_flag (
      name VARCHAR(255) PRIMARY KEY,
      enabled BOOLEAN NOT NULL DEFAULT false
    );
  3. Set up the notification trigger in PostgreSQL:

    CREATE OR REPLACE FUNCTION notify_feature_flag_changes()
    RETURNS trigger AS $$
    BEGIN
      PERFORM pg_notify('feature_flag_changes', NEW.name);
      RETURN NEW;
    END;
    $$ LANGUAGE plpgsql;
    
    CREATE TRIGGER feature_flag_changes_trigger
    AFTER UPDATE ON hub_feature_flag
    FOR EACH ROW
    EXECUTE FUNCTION notify_feature_flag_changes();

Usage

import { FeatureFlagService } from '@weaverslab/feature-flags'

// Initialize the service
const featureFlags = new FeatureFlagService()

// Check if a feature is enabled
if (featureFlags.isEnabled('my-feature')) {
   // Feature is enabled
   console.log('Feature is active!')
}

// Listen for feature flag updates
featureFlags.onUpdate(() => {
   console.log('Feature flags have been updated!')
})

// Set database URL programmatically (optional)
FeatureFlagService.setDatabaseUrl('postgresql://user:password@localhost:5432/database')

API Reference

FeatureFlagService

The main class for managing feature flags.

Methods

  • isEnabled(flagName: string): boolean

    • Checks if a specific feature flag is enabled
    • Returns false if the flag doesn't exist
  • onUpdate(callback: () => void): void

    • Registers a callback to be called when feature flags are updated
  • static setDatabaseUrl(url: string): void

    • Sets the database URL programmatically

Database Schema

The library expects a PostgreSQL table with the following structure:

CREATE TABLE hub_feature_flag (
  name VARCHAR(255) PRIMARY KEY,
  enabled BOOLEAN NOT NULL DEFAULT false
);

Performance Considerations

  • The library uses an LRU cache with a maximum of 100 entries and a TTL of 60 seconds
  • Real-time updates are handled through PostgreSQL notifications
  • Database connections are managed efficiently using connection pooling

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT © CodeWeavers