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

@release-anchor/js

v1.1.3

Published

ReleaseAnchor JavaScript SDK for feature flag evaluation

Downloads

328

Readme

npm license node TypeScript bundle size

JavaScript / Node.js SDK for ReleaseAnchor feature flags. Works in Node.js and browser environments. Zero dependencies.

Documentation · npm · releaseanchor.com


Installation

npm install @release-anchor/js
# or
pnpm add @release-anchor/js
# or
yarn add @release-anchor/js

Quick start

import { ReleaseAnchor } from "@release-anchor/js";

const client = new ReleaseAnchor({
  apiKey: process.env.RELEASE_ANCHOR_KEY,
});

const result = await client.evaluate("dark-mode", "user-123");
if (result.value) {
  // feature is on for this user
}
// result: { value: boolean, matchedRuleType: string | null, error: object | null }

evaluate() returns an EvaluateResponse object with:

  • value — the boolean result
  • matchedRuleType"STATIC" | "SEGMENT" | "PERCENTAGE" | null
  • error — populated on technical failures (network, timeout, etc.), null on success

Configuration

const client = new ReleaseAnchor({
  apiKey: "ra_xxx",          // Required — get from the API Keys page
  apiVersion: "v1",          // "v1" | "v2". Default: "v1"
  baseUrl: "https://...",    // Override API base URL. Default: https://api.releaseanchor.com
  timeout: 5000,             // Request timeout in ms. Default: 5000
  cacheTtlMs: 30_000,        // In-memory cache TTL in ms. Set to 0 to disable. Default: 30000
  defaultValue: false,       // Fallback value on technical errors. Default: false
  strict4xx: false,          // Throw StrictHttpError on unexpected 4xx. Default: false
  logger: console.warn,      // Called on technical errors. Default: console.warn
});

evaluate(flagKey, userIdentifier, defaultValue?)

Evaluates a single flag for a user. Results are cached per flagKey + userIdentifier for cacheTtlMs milliseconds. Concurrent calls for the same key are deduplicated — only one HTTP request is made.

const result = await client.evaluate("dark-mode", "user-123");

// Per-call defaultValue overrides the instance-level default
const result = await client.evaluate("dark-mode", "user-123", true);

evaluateBulk(flagKey, userIdentifiers[], defaultValue?)

Evaluates a single flag for multiple users in one request.

const results = await client.evaluateBulk("dark-mode", ["user-1", "user-2"]);
// results: Record<string, EvaluateResponse>

for (const [userId, result] of Object.entries(results)) {
  if (result.value) console.log(`${userId}: feature on`);
}

Missing keys in the server response are filled with a fallback entry. Extra keys are ignored.

Cache management

client.clearCache();                        // Clear entire cache
client.clearCache("dark-mode");             // Clear all entries for a flag
client.clearCache("dark-mode", "user-123"); // Clear a specific entry

Cleanup

Call destroy() during app shutdown or test teardown to stop the background cache cleanup timer:

client.destroy();
// afterAll(() => client.destroy()); // in test suites

Error handling

Technical errors (network, timeout, 401, 429, 5xx, parse failure) are caught internally, logged via logger, and returned as a fallback response — the SDK never throws by default.

const result = await client.evaluate("dark-mode", "user-123");
if (result.error) {
  // result.error.type: "NETWORK_ERROR" | "TIMEOUT" | "UNAUTHORIZED" |
  //                    "RATE_LIMITED" | "HTTP_ERROR" | "PARSE_ERROR"
  // result.error.message: string
}
// result.value is always safe to use — it will be defaultValue on error

strict4xx (development helper)

Set strict4xx: true to throw StrictHttpError on unexpected 4xx responses instead of silently falling back. Useful for catching misconfiguration early:

import { ReleaseAnchor, StrictHttpError } from "@release-anchor/js";

const client = new ReleaseAnchor({ apiKey: "...", strict4xx: true });

try {
  const result = await client.evaluate("dark-mode", "user-123");
} catch (err) {
  if (err instanceof StrictHttpError) {
    console.error("Unexpected HTTP error:", err.status);
  }
}

Timeouts are never thrown — detect them via result.error.type === "TIMEOUT".

TypeScript

The SDK ships with full TypeScript types — no @types package needed.

import { ReleaseAnchor, type EvaluateResponse, StrictHttpError } from "@release-anchor/js";

const client = new ReleaseAnchor({ apiKey: process.env.RELEASE_ANCHOR_KEY! });
const result: EvaluateResponse = await client.evaluate("my-flag", userId);

License

MIT — see LICENSE