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

@rudderjs/pennant

v1.0.5

Published

Feature flags for RudderJS — define, check, scope, Lottery rollout, database/memory drivers

Downloads

697

Readme

@rudderjs/pennant

Feature flags for RudderJS — define features, check activation, scope to users/teams, and gradually roll out with Lottery.

Installation

pnpm add @rudderjs/pennant

Setup

PennantProvider is picked up by auto-discoverypnpm rudder providers:discover is all that's needed.

Usage

Defining Features

import { Feature, Lottery } from '@rudderjs/pennant'

// Boolean feature
Feature.define('dark-mode', () => true)

// Rich value
Feature.define('max-uploads', () => 10)

// Scoped to user
Feature.define('beta-dashboard', (scope) => {
  return scope?.id === 1  // only for user 1
})

// Gradual rollout — 10% of users
Feature.define('new-checkout', () => Lottery.odds(1, 10))

Checking Features

if (await Feature.active('dark-mode')) {
  // feature is on
}

const maxUploads = await Feature.value<number>('max-uploads')

Scoped Checks

const user = { id: 1, name: 'Alice' }

await Feature.for(user).active('beta-dashboard')  // true
await Feature.for(user).value('max-uploads')       // 10

// Bulk check
await Feature.for(user).values(['dark-mode', 'beta-dashboard'])
// { 'dark-mode': true, 'beta-dashboard': true }

Manual Activation

// Force a feature on for a specific scope
await Feature.activate('beta-dashboard', user)

// Force off
await Feature.deactivate('beta-dashboard', user)

// Clear all stored values (re-resolves on next check)
await Feature.purge('beta-dashboard')

Lottery (Gradual Rollout)

Feature.define('new-ui', () => Lottery.odds(1, 10))  // 10% chance

// First check resolves the lottery and persists the result.
// Subsequent checks for the same scope return the same value.
await Feature.active('new-ui')       // true or false (stable)
await Feature.active('new-ui')       // same result as above

Middleware

Block routes when a feature is inactive:

import { FeatureMiddleware } from '@rudderjs/pennant'

router.get('/beta', FeatureMiddleware('beta-dashboard'), handler)
// Returns 403 if the feature is not active for req.user

Drivers

| Driver | Description | |---|---| | MemoryDriver | In-memory Map — default. No persistence across restarts. |

Testing

import { Feature } from '@rudderjs/pennant'

const fake = Feature.fake()

// Override feature values
fake.override('dark-mode', true)
fake.override('beta', false)

// Assertions
await Feature.active('dark-mode')
fake.assertChecked('dark-mode')
fake.assertNotChecked('other-feature')
fake.assertCheckedFor('dark-mode', { id: 1 })

fake.restore()

API Reference

| Method | Description | |---|---| | Feature.define(name, resolver) | Register a feature with a resolver function | | Feature.active(name, scope?) | Check if a feature is active (boolean) | | Feature.value<T>(name, scope?) | Get the resolved value of a feature | | Feature.values(names, scope?) | Bulk-resolve multiple features | | Feature.for(scope) | Create a scoped feature checker | | Feature.activate(name, scope?) | Force-activate a feature | | Feature.deactivate(name, scope?) | Force-deactivate a feature | | Feature.purge(name) | Clear all stored values for a feature | | Feature.fake() | Install fake driver for testing | | Lottery.odds(winners, total) | Create a lottery for gradual rollout | | FeatureMiddleware(name) | Middleware that returns 403 if feature is inactive | | pennant(config?) | Service provider factory |