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

featurehub-yaml-interceptor

v1.0.1

Published

FeatureHub local YAML file value interceptor for Node.js

Readme

featurehub-yaml-interceptor

Local YAML file feature overrides for the FeatureHub JavaScript SDK.

This package provides two classes for working with feature flags from a local YAML file during development and testing, without needing a live FeatureHub connection. They are intentionally not suited for production use — the YAML file is read from the local filesystem and is not authenticated or versioned by FeatureHub.

Node.js only. Requires Node.js ≥ 20.


YAML file format

Both classes read from a YAML file with a single top-level flagValues map. Keys are feature flag keys; values are the overridden values.

# featurehub-features.yaml
flagValues:
  my-boolean-flag: true
  my-string-flag: "hello world"
  my-number-flag: 42
  my-json-flag:
    warehouse: east
    capacity: 500
  my-null-flag: ~

Type inference follows these rules:

| YAML value | Inferred type | |------------|---------------| | true / false (native or string) | Boolean | | Integer or float | Number | | Any other string | String | | Object or array | JSON (serialised with JSON.stringify) | | ~ / null | String with no value |

The default file name is featurehub-features.yaml in the current working directory. This can be overridden by passing a path to the constructor or by setting the FEATUREHUB_LOCAL_YAML environment variable.


Installation

npm install featurehub-yaml-interceptor
# or
pnpm add featurehub-yaml-interceptor

Classes

LocalYamlValueInterceptor

Intercepts individual feature lookups and substitutes values from the YAML file, leaving all other features unaffected. This is the right choice when you want to override a subset of flags during development while the rest continue to come from FeatureHub normally.

It implements FeatureValueInterceptor and is registered with the config, not with the repository directly, so it integrates cleanly with the rest of the interceptor chain.

import { EdgeFeatureHubConfig } from 'featurehub-javascript-node-sdk';
import { LocalYamlValueInterceptor } from 'featurehub-yaml-interceptor';

const fhConfig = new EdgeFeatureHubConfig(edgeUrl, apiKey);

fhConfig.addValueInterceptor(new LocalYamlValueInterceptor());

await fhConfig.init();

File path resolution

The file path is resolved in this order of precedence:

  1. The filename argument passed to the constructor
  2. The FEATUREHUB_LOCAL_YAML environment variable
  3. featurehub-features.yaml in the current working directory
// Explicit path
new LocalYamlValueInterceptor('./config/local-flags.yaml');

// Via environment variable (constructor called with no argument)
// FEATUREHUB_LOCAL_YAML=./config/local-flags.yaml
new LocalYamlValueInterceptor();

Live reload during development

Pass { watchForChanges: true } to poll the YAML file every 500 ms and pick up edits without restarting the process. This is useful when iterating on feature flag scenarios locally.

fhConfig.addValueInterceptor(
  new LocalYamlValueInterceptor('./local-flags.yaml', { watchForChanges: true })
);

Call interceptor.close() to stop the file watcher when it is no longer needed.

Locked features

The interceptor does not check whether a feature is locked — it will override locked features the same as unlocked ones. If you need to respect locks, check featureState?.l before registering the interceptor, or use a wrapper.


LocalYamlFeatureStore

Reads the YAML file once at construction and loads all entries into the FeatureHub repository as FeatureState objects. This replaces the repository's feature state entirely from the file, making it useful for unit tests or offline development scenarios where no FeatureHub connection is available at all.

Unlike LocalYamlValueInterceptor, the feature store does not intercept individual lookups — it populates the repository directly, so fhConfig.init() is not required.

import { EdgeFeatureHubConfig } from 'featurehub-javascript-node-sdk';
import { LocalYamlFeatureStore } from 'featurehub-yaml-interceptor';

const fhConfig = new EdgeFeatureHubConfig(edgeUrl, apiKey);

// Populate the repository from the YAML file — no network call needed
new LocalYamlFeatureStore(fhConfig);

// Features are immediately available
const ctx = await fhConfig.newContext().build();
console.log(ctx.getBoolean('my-boolean-flag')); // true

Each feature entry is assigned a stable synthetic ID derived from the first 8 hex characters of the SHA-256 hash of its key, so IDs are consistent across runs without requiring a FeatureHub server.

LocalYamlFeatureStore does not support live reload; it reads the file exactly once. For iterative development with hot-reload, use LocalYamlValueInterceptor with { watchForChanges: true } instead.


Choosing between the two classes

| | LocalYamlValueInterceptor | LocalYamlFeatureStore | |---|---|---| | Overrides only listed flags | Yes — other flags still come from FeatureHub | No — replaces all repository state | | Requires live FeatureHub connection | Yes (for non-overridden flags) | No | | Live reload | Yes (watchForChanges: true) | No | | Suitable for unit tests | Yes | Yes (simpler setup) | | Suitable for local dev with partial overrides | Yes | No |


License

MIT