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

@oratis/rate-limit

v1.0.0

Published

Zero-dependency in-memory sliding-window rate limiter for Node. Tiny, fully typed, self-pruning, ESM + CJS.

Readme

@oratis/rate-limit

npm version bundle size license types

A zero-dependency, in-memory sliding-window rate limiter for Node. One small file, fully typed, self-pruning so it won't leak memory. Perfect for protecting an API route, a queue worker, or a CLI on a single instance — no Redis required.

  • 🪶 Zero dependencies, tiny footprint
  • 🎚️ True sliding window (not a coarse fixed bucket)
  • 🧹 Self-pruning — an unref'd timer sweeps stale keys; never keeps your process alive
  • 🧰 Class API (peek / reset / dispose) and a one-liner
  • 📦 Ships ESM + CJS + types

Single-process by design. Behind a load balancer each instance limits independently — fine for coarse abuse protection; use a shared store (Redis) when you need a strict global limit.

Install

npm install @oratis/rate-limit

Quick start

import { rateLimit } from "@oratis/rate-limit";

// Allow 100 requests per minute per IP.
const { allowed, remaining, resetMs } = rateLimit(ip, 100, 60_000);
if (!allowed) {
  return new Response("Too Many Requests", {
    status: 429,
    headers: { "Retry-After": String(Math.ceil(resetMs / 1000)) },
  });
}

Class API

Reach for RateLimiter when you want peek, reset, or explicit lifecycle control:

import { RateLimiter } from "@oratis/rate-limit";

const limiter = new RateLimiter({ limit: 5, windowMs: 10_000 });

limiter.check("user:42");   // record a request → RateLimitResult
limiter.peek("user:42");    // inspect without recording
limiter.reset("user:42");   // forget one key
limiter.reset();            // forget everything
limiter.dispose();          // stop the prune timer when you're done

RateLimitResult

| Field | Type | Meaning | | --- | --- | --- | | allowed | boolean | Whether the request is within the limit. | | remaining | number | Requests left in the current window (0 when blocked). | | resetMs | number | Ms until capacity frees up (great for a Retry-After header). |

new RateLimiter(options)

| Option | Type | Default | Description | | --- | --- | --- | --- | | limit | number | — | Max requests per rolling window (> 0). | | windowMs | number | — | Window length in ms (> 0). | | pruneIntervalMs | number | 300000 | Stale-key sweep interval. 0 disables the timer. |

How it works

Each key keeps the timestamps of its requests. On every check, timestamps older than windowMs are dropped; if what remains is below limit, the request is allowed and recorded. This gives a true rolling window — no burst at the fixed-bucket boundary that naive counters suffer from.

License

MIT © oratis