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

@yaebal/throttle

v0.1.1

Published

yaebal throttle plugin - priority outbound scheduler with Telegram buckets.

Readme

@yaebal/throttle

priority outbound scheduler for Telegram Bot API calls. throttle enforces Telegram-shaped buckets, supports per-method limits, priority queueing, shared storage, abort/cancel, metrics, and retry_after feedback from @yaebal/again.

install

pnpm add @yaebal/throttle

usage

import { throttle } from "@yaebal/throttle";

const limiter = throttle(bot.api, {
	globalPerSec: 30,
	perChatPerSec: 1,
	perGroupPerMin: 20,
	perMethod: {
		sendVideo: { privateChat: { limit: 1, windowMs: 5_000 }, priority: -5 },
		answerCallbackQuery: { privateChat: false, group: false, priority: 20 },
	},
});

console.log(limiter.metrics.pending);

installable plugin form:

const transport = throttle({ globalPerSec: 30 });

const bot = new Bot(token).install(transport);
transport.handle.metrics.acquired;

the old compatibility mode still works:

throttle(bot.api, { minIntervalMs: 100 });

buckets

every request can acquire multiple buckets atomically:

  • global caps the whole bot, default 30/s.
  • private:<chat_id> caps one private chat, default 1/s.
  • group:<chat_id> caps one group or supergroup, default 20/min.
  • method:<method>:... isolated method buckets are created for perMethod limit overrides.

control-plane methods such as getMe, getUpdates, getWebhookInfo, logOut, and close are excluded by default.

priority and cancellation

import { withThrottle } from "@yaebal/throttle";

await bot.api.sendMessage(
	withThrottle({ chat_id, text: "urgent" }, { priority: 100 }),
);

const controller = new AbortController();
const queued = bot.api.sendMessage(
	withThrottle({ chat_id, text: "cancel me" }, { signal: controller.signal }),
);

controller.abort();
await queued;

you can also cancel queued work from the handle:

limiter.cancel({ method: "sendMessage" });
limiter.cancel({ bucket: `private:${chatId}` });

shared storage

the built-in memoryThrottleStorage() is process-local. for multi-process or multi-region bots, pass a storage adapter whose take(buckets, now) atomically checks and records all buckets.

import type { ThrottleStorage } from "@yaebal/throttle";

const redisStorage: ThrottleStorage = {
	async take(buckets, now) {
		// check all bucket windows in Redis, record all hits only when every bucket fits
		return { ok: true, waitMs: 0 };
	},
	async freeze(bucketKey, until) {
		// store a retry_after freeze shared by every worker
	},
};

throttle(bot.api, { storage: redisStorage });

metrics and retry_after learning

throttle exposes live metrics and emits events for queueing, acquisition, rejection, cancellation and learned flood-waits.

const limiter = throttle(bot.api, {
	onEvent: (event) => console.log(event.type),
});

limiter.metrics.pending;
limiter.metrics.totalWaitMs;

when telegram returns 429 with response_parameters.retry_after, @yaebal/core stores it on TelegramError.parameters.retry_after. throttle observes that error and freezes the affected buckets, while @yaebal/again performs the awaited retry.


part of yaebal - a type-safe, runtime-agnostic Telegram Bot API framework. MIT.