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

slim-feature-toggle

v0.2.10

Published

Slim Feature / Version Toggle for Javascript Based Applications

Readme

Slim Feature Toggle

slim-feature-toggle is a JavaScript library for toggling content based on features and version management.

slim-feature-toggle fits for both client and server applications and is agnostic to frameworks

The following example will guide you through it

// Welcome to CuteCorp. 
// These are the cute Features and Sub-Features we develop in our app
// We use the 'enabled' property to set each feature's availability
const appFeatures = {
  PUPPIES: {
    enabled: true,
    POODLES: {
      enabled: true
    },
    LABRADORS: {
      enabled: false
    }
  },
  KITTEN: { enabled: true },
  BABIES: { enabled: true }
};

To set up the configuration needed,

import the featureToggle module at Application Start and set the app's features:

// inside App.js / index.js / server.js / main.js:
const { featureToggle } = require('slim-feature-toggle');
featureToggle.setAppFeatures(appFeatures); 

After setting the configuration we are good to go.

Simply import the featureToggle module into your code and control the application flow using one of the following methods:

// =========================================
// isFeatureEnabled - a Simple Control Flow:
// =========================================
const { featureToggle } = require('slim-feature-toggle');
const { isFeatureEnabled } = featureToggle;

if (isFeatureEnabled('PUPPIES')) {
  console.log(`TODO - Render the PuppyList component here ... `)
} else {
  console.log(`TODO - Engage a free monthly puppy subscription offer here ...`);
}

// feature set arrays are also supported:
if (isFeatureEnabled(['KITTEN', 'BABIES'])) {
  console.log(`Do stuff if both KITTEN and BABIES are enabled`);
}

// nested features traversal are also supported using . notation:
if (isFeatureEnabled('PUPPIES.POODLES')) {
  console.log(`Run if both PUPPIES feature and POODLES sub-feature are enabled`);
}



// =============================================================================
// featureToggleRunCallback - Execute a callback only if the feature is enabled
// =============================================================================
const { featureToggle } = require('slim-feature-toggle');
const { featureToggleRunCallback } = featureToggle;

featureToggleRunCallback('KITTEN', () => {
  // Execute some super cute kitty logic here ....

  // NOTE - this callback will execute only if the KITTEN feature is enabled,
  //        otherwise it will be skipped.

});



// ======================================================================
// featureToggleRunPromise - Resolve a promise if the feature is enabled, 
//                           Otherwise reject
// ======================================================================
const { featureToggle } = require('slim-feature-toggle');
const { featureToggleRunPromise } = featureToggle;

featureToggleRunPromise('BABIES')
  .then(() => console.log('resolves only if BABIES feature is enabled'))
  .catch(() => console.log('rejects if BABIES feature is disabled'));