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 🙏

© 2025 – Pkg Stats / Ryan Hefner

ration.js

v2.1.0

Published

100% Vanilla Javascript Rate Limiting / DDOS Protection Library

Downloads

10

Readme

Ration.js

Author: Austin K. Smith

Website: Github

Description: 100% Vanilla Javascript Rate Limiting / DDOS Protection Library

License: Artistic License 2.0

About

Ration.js is 100% Vanilla Javascript Rate Limiting / DDOS Protection Library for use with Node.js / Express, inspired by Network Tarpits it works the same way to intentionally slow down requests from users who are making too many requests within a limited timeframe.

Install

  • Add Ration.js to your project using the instructions below

Node

  • Use npm install to add the project to your dependencies npm install --save ration.js
  • Require the npm module in your app.js file
    const ration = require('ration.js');

Then make sure your app is set to use ration with the following

// Declare Application
let app = express();

/* Set Ration.js Options */
const rations = {
  maxRequestsPerTimeFrame: 600,
  timeFrameInSeconds: 30,
  removeRecordsAfter: (1000 * 60 * 5),
  dropConnections: false
};

/* Initialize Ration.js */
rationjs.setRations(rations);

/* Use Ration.js */
app.use(rationjs.startRations);

Ration.js Options

  • maxRequestsPerTimeFrame - This is the maximum number of requests you want to allow an unique visitor within the timeFrameInSeconds time period. Value should be an Integer - Defaults to 600.
  • timeFrameInSeconds - This is the time frame you want to limit the number of requests within eg. Use 1 to limit requests by individual seconds - Defaults to 30
  • removeRecordsAfter - This is the amount of time since the requestors last request that the requestors records are kept in memory - milliseconds - Defaults to 30000 (ie. 5 minutes).
  • dropConnections - This new option changes how the library operates to forcabily drop connections from users who have exceeded their rations instead of processing requests with a delay.

How it works

The library acts as a middleware layer for incoming requests to your Node.js/Express application, with each unique visitor a request record is created and saved internally to keep track of time interval between each new request and the previous request. If the number of requests exceeds the set limit of requests within the set time threadshold, requests by the offending users are then delayed using a delayMultiplier, this delayMultiplier is doubled for each request exceeding the number of requests allowed within the set time.

If the time difference between the last request and the current request exceeds the removeRecordsAfter time frame setting, the request count for the user is reset to 1.

If there are no new requests from a unique visitor within the removeRecordsAfter time frame setting, their request records are removed automatically to prevent the visits log from growing using too much memory.