@wlcr/feature-flags
v1.0.0
Published
WLCR Feature Flags Helper
Readme
WLCR Feature Flags
Small, dependency-free helper for WLCR feature flags.
Usage
import { createFeatureFlags } from "wlcr-feature-flags";
const flags = createFeatureFlags("rallycrew", { timeoutMs: 1500 });
await flags.ready;
const isOn = flags.isEnabled("test");
const value = flags.getValue("number-flag", 0);
const all = flags.getFlags();
const info = flags.getInfo();Scripts
npm run buildbuilds CJS + ESM and type declarations.npm testruns the minimal Node.js test harness.
API
createFeatureFlags(handle, options)handle: the WLCR handle.options.timeoutMs: optional request timeout.options.fetch: optional custom fetch implementation.options.headers: optional headers.
Returned client:
ready: promise that resolves after initial fetch.refresh(): re-fetches the JSON file.getFlags(): returns a record of all flags.getFlag(key): returns a single flag ornull.getValue(key, fallback): returns the flag value or fallback.isEnabled(key, fallback): convenience boolean for boolean flags.getInfo(): returns flag set metadata (no flags).getLastError(): last error message, if any.
This package never throws; all methods return safe values on errors.
