WLCR Feature Flags Helper
npm install @wlcr/feature-flagsSmall, dependency-free helper for WLCR feature flags.
``ts
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();
`
- npm run build builds CJS + ESM and type declarations.npm test
- runs the minimal Node.js test harness.
- 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 or null.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.