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

@streetjs/flags

v1.0.0

Published

StreetJS feature-flag foundation: typed boolean/multivariate flags with attribute targeting rules and deterministic percentage rollouts (stable per-subject bucketing), a pluggable flag store, and a fast in-memory registry. Zero runtime dependencies; edge/

Readme

@streetjs/flags

The StreetJS feature-flag foundation: typed boolean and multivariate flags with attribute targeting rules and deterministic percentage rollouts (sticky per-subject bucketing), a fast in-memory registry, and a pluggable store seam. Zero runtime dependencies — safe on Node, edge runtimes, and in the browser.

Install

npm install @streetjs/flags

Usage

import { FlagRegistry, booleanFlag } from '@streetjs/flags';

const flags = new FlagRegistry([
  booleanFlag('new-review-player', {
    // Enterprise always on; everyone else via a 25% staged rollout.
    rules: [{ when: { plan: 'enterprise' }, value: true }],
    rollout: { variants: [{ value: true, weight: 25 }] },
  }),
]);

if (flags.isEnabled('new-review-player', { key: userId, attributes: { plan } })) {
  // ...ship the new experience
}

Evaluation order

For each flag, evaluation resolves in this order (with the reason exposed by evaluateDetailed):

  1. enabled === falseoffValue (a kill switch). booleanFlag sets offValue: false, so a disabled boolean flag is off.
  2. First matching targeting rule (rules are ordered; first match wins). A rule's when is an AND of conditions; an array condition matches by membership; an empty when is a catch-all.
  3. Percentage rollout — the subject's key is hashed with the flag key into a stable bucket in [0, 100); the first variant whose cumulative weight covers the bucket wins. The same subject always lands in the same bucket (sticky), and buckets beyond the total weight fall through.
  4. default otherwise.

Multivariate flags

const theme: FlagDefinition<'classic' | 'compact'> = {
  key: 'editor-theme',
  default: 'classic',
  rules: [{ when: { beta: true }, value: 'compact' }],
};
flags.register(theme);
flags.evaluate<'classic' | 'compact'>('editor-theme', { attributes: { beta: true } }); // 'compact'

Loading from a store

Evaluation is synchronous (flag checks belong on hot paths); hydrate definitions from any backend via the FlagStore seam:

import { FlagRegistry, InMemoryFlagStore } from '@streetjs/flags';

const store = new InMemoryFlagStore(initialDefs); // or your DB/Redis-backed store
const flags = await FlagRegistry.fromStore(store);
// later, on change:
await flags.loadFrom(store);

An unknown flag key throws UnknownFlagError — a missing flag is a bug, not a silent false.

API

| Export | Description | | ------ | ----------- | | FlagRegistry | In-memory registry: register, evaluate, evaluateDetailed, isEnabled, setEnabled, has, get, keys, loadFrom, fromStore. | | booleanFlag(key, opts) | Ergonomic boolean-flag builder (off by default; offValue: false). | | evaluateFlag / evaluateFlagDetailed | Pure evaluation of a FlagDefinition against a FlagContext. | | fnv1a32 / stableBucket | Pure, dependency-free hashing used for rollouts. | | FlagStore / InMemoryFlagStore | Pluggable definition source + in-memory default. | | FLAG_REGISTRY | DI token for a shared registry. | | UnknownFlagError | Thrown when evaluating an unregistered key. |

Design notes

  • Deterministic, dependency-free bucketing. Rollouts use 32-bit FNV-1a over flagKey:subjectKey, so assignments are sticky and reproducible without any crypto/runtime dependency.
  • Framework, not product. This owns the flag mechanics; which flags exist and what they gate is product code.

License

MIT — see LICENSE.