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

@klarlabs-studio/fortify-adaptive

v0.1.0

Published

Adaptive concurrency limiter (AIMD, Vegas, Gradient2) for Fortify

Readme

@klarlabs-studio/fortify-adaptive

Adaptive concurrency limiter (AIMD, Vegas, Gradient2) for the Fortify-TS resilience library.

Mirrors the Go fortify/adaptive package.

Installation

npm install @klarlabs-studio/fortify-adaptive
# or
pnpm add @klarlabs-studio/fortify-adaptive

How it works

Unlike a static bulkhead (fixed concurrency cap), the adaptive limiter starts at initialLimit and tunes its in-flight cap at runtime:

  • aimd (default): additive increase — +1 to the limit on every successThreshold consecutive successes (up to maxLimit); multiplicative decrease — halve on any failure (down to minLimit).
  • vegas: RTT-aware. Tracks the minimum observed latency (no-load baseline) and an EMA of recent latencies, estimates the induced queue depth, and grows the limit when the queue is shallow (< vegasAlpha) / shrinks it when deep (> vegasBeta). Reacts to rising latency before failures appear.
  • gradient2: smoothed gradient-of-RTT controller. Reacts more aggressively than Vegas under variable load.

Usage

import { AdaptiveLimiter, AdaptiveLimitExceededError } from '@klarlabs-studio/fortify-adaptive';

const limiter = new AdaptiveLimiter<Response>({
  algorithm: 'aimd',
  initialLimit: 10,
  minLimit: 2,
  maxLimit: 100,
  successThreshold: 20,
  onLimitChange: (oldLimit, newLimit) => console.log(`limit ${oldLimit} -> ${newLimit}`),
});

try {
  const result = await limiter.execute(async (signal) => downstream(signal));
} catch (error) {
  if (error instanceof AdaptiveLimitExceededError) {
    // shed load
  }
}

Configuration

| Option | Type | Default | Description | | -------------------- | ------------------------------------- | -------- | ------------------------------------------------------- | | algorithm | 'aimd' \| 'vegas' \| 'gradient2' | 'aimd' | Tuning strategy. | | initialLimit | number | 10 | Starting cap, clamped into [minLimit, maxLimit]. | | minLimit | number | 1 | Floor for multiplicative decrease. | | maxLimit | number | 200 | Ceiling for additive increase. | | successThreshold | number | 10 | AIMD: consecutive successes before +1. | | vegasAlpha | number | 3 | Vegas: low-water queue mark (grow below). | | vegasBeta | number | 6 | Vegas: high-water queue mark (shrink above). | | vegasMinSamples | number | 10 | Vegas: min RTT samples before adjusting. | | gradientMinSamples | number | 10 | Gradient2: min RTT samples before adjusting. | | gradientSmoothing | number | 0.2 | Gradient2: EMA smoothing in (0, 1]. | | onLimitChange | (old: number, new: number) => void | — | Limit-change callback (metrics). | | clock | () => number | — | Monotonic ms clock; defaults to performance.now(). | | logger | FortifyLogger | — | Structured logger. |

Composition

Use with the middleware chain via chain.withAdaptive(limiter). Place it outermost (before bulkhead) to shed load before any pattern-specific work occurs.

License

MIT