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

@ulta-plus/extension-feature-toggle

v1.0.6

Published

Feature toggle with app version, browser and rollout rules

Readme

extension-feature-toggle

Feature toggle with rules: app version, browser (name + min version), and rollout percentage.

Install

npm install @ulta-plus/extension-feature-toggle

Usage

getContext is called by the library when evaluating rules. It must return data from your Chrome extension environment: extension version from chrome.runtime.getManifest(), browser name and version from your UA/browser detector, and deviceId from your auth if you use rollout.

import { featureStore } from "@ulta-plus/extension-feature-toggle";

featureStore.init({
  features: ["feature-a", "feature-b"],
  getConfig: () => fetch("/api/features").then((r) => r.json()),
  getContext: () => {
    const manifest = chrome.runtime.getManifest();
    const { browserName, browserVersion } = detectBrowser(); // from UA or chrome.runtime
    return {
      appVersion: manifest.version,
      browserName,
      browserVersion,
      deviceId: getUserId(), // from your auth/storage if needed for rollout
    };
  },
  setStorage: (data) => chrome.storage.local.set({ featureToggle: data }),
  getStorage: () =>
    chrome.storage.local
      .get("featureToggle")
      .then((r) => r.featureToggle ?? null),
});

const snapshot = featureStore.getSnapshot();
featureStore.subscribe(() => {});
await featureStore.getSnapshotAsync();
await featureStore.setFeatureValues({ "feature-a": true });
await featureStore.reset();

Config format (backend response)

The rollout percentage is set by the backend in each feature rule (rollout: 0–1, e.g. 0.5 = 50%). The extension does not pass the percentage; it only passes deviceId (or another stable string) in getContext(). The library hashes that and checks if the user falls inside the rolled-out fraction.

Each feature value: { "app-version"?: string, browser?: Record<string, number>, rollout?: number }.

  • app-version — min extension version (semver).
  • browser — min major per browser, e.g. { "chrome": 120, "firefox": 90 }. If omitted or empty, the feature is enabled for all browsers and versions (no browser filter).
  • rollout — fraction 0–1 (0.5 = 50%), from backend; extension supplies deviceId in context for the hash. If omitted, the feature is enabled for 100% of users (no rollout filter).

Example: JSON returned by getConfig() (backend response):

{
  "switch-internet": {
    "app-version": "6.3.7",
    "browser": { "chrome": 120, "firefox": 90 },
    "rollout": 0.5
  },
  "lite": {
    "app-version": "1.0.0"
  },
  "media": {
    "app-version": "2.0.0",
    "browser": { "chrome": 100 },
    "rollout": 1
  }
}

Only feature keys that are in the features array passed to init() are evaluated; other keys in this response are ignored.

API

  • featureStore.init(options) — call once with features list, getConfig, getContext, setStorage, getStorage.
  • featureStore.subscribe(listener) — returns unsubscribe.
  • featureStore.getSnapshot() — current state (sync).
  • featureStore.getSnapshotAsync() — state with persisted overrides (async).
  • featureStore.setFeatureValues(partial) — local overrides.
  • featureStore.reset() — clear overrides.

Export FeatureToggleStore class to create your own instance instead of the default singleton.