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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@xfeature/core

v1.0.5

Published

A powerful and flexible feature flag library for JavaScript and TypeScript applications that allows you to control feature rollouts, A/B testing, and feature toggles with ease.

Readme

@xfeature/core

A powerful and flexible feature flag library for JavaScript and TypeScript applications that allows you to control feature rollouts, A/B testing, and feature toggles with ease.

Installation

bun add @xfeature/core

Quick Start

1. Define your features

import { defineFeature, registerFeatures } from '@xfeature/core';

export const Features = registerFeatures({
  UserManagement: defineFeature('user-management', {
    Registration: defineFeature('registration'),
    Profile: defineFeature('profile', {
      Avatar: defineFeature('avatar'),
      Preferences: defineFeature('preferences')
    })
  }),
  Analytics: defineFeature('analytics'),
  NewUI: defineFeature('new-ui')
});

2. Use features in your code

import { isFeatureEnabled } from '@xfeature/core';
import { Features } from './features';

if (isFeatureEnabled(Features.UserManagement)) {
  // New user management logic
} else {
  // Fallback to old logic
}

Environment-based Feature Loading

Features are automatically loaded from environment variables when you register them. By default, the FEATURES environment variable is used:

# Enable specific features
FEATURES="user-management,analytics,user-management.profile.avatar"

# Or in your .env file
FEATURES=user-management,analytics,new-ui

Custom Environment Variable

You can specify a different environment variable:

export const Features = registerFeatures({
  UserManagement: defineFeature('user-management'),
  Analytics: defineFeature('analytics'),
  NewUI: defineFeature('new-ui')
}, {
  parseEnv: 'APP_FEATURES'  // Use APP_FEATURES instead of FEATURES
});

API Reference

defineFeature(name, subfeatures?)

Creates a new feature definition.

const myFeature = defineFeature('my-feature', {
  subFeature: defineFeature('sub-feature')
});

registerFeatures(features, options?)

Registers features in the global registry and automatically loads them from environment variables.

registerFeatures(Features, {
  override: true,           // Clear existing features first
  parseEnv: 'APP_FEATURES'  // Load from APP_FEATURES env variable
});

loadFeatures(features, override?)

Loads and enables specific features.

loadFeatures([Features.UserManagement, Features.Analytics]);

loadFeaturesFromString(featuresString)

Loads features from a comma-separated string.

loadFeaturesFromString('user-management,analytics,new-ui');

isFeatureEnabled(feature)

Checks if a feature is currently enabled.

if (isFeatureEnabled(Features.UserManagement)) {
  // Feature is enabled
}

getFeature(featureName)

Retrieves a feature by name from the registry.

const feature = getFeature('user-management');

Feature Object Methods

Each feature object comes with built-in methods:

const feature = defineFeature('my-feature');

// Get feature name
feature.$name(); // Returns: 'my-feature'

// Enable/disable feature
feature.$enable();
feature.$disable();

// Check status
feature.$isEnabled(); // Returns: boolean
feature.$isDisabled(); // Returns: boolean

// Create disabled version
const disabledFeature = feature.$asDisabled();

License

This project is licensed under the MIT License - see the LICENSE file for details.