Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

request-rate-clock

Package Overview
Dependencies
Maintainers
0
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

request-rate-clock

Rateclock provides a clock mechanism to work with api rate limits

  • 0.1.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11
decreased by-81.36%
Maintainers
0
Weekly downloads
 
Created
Source

Request Rate Clock

This package provides a clock that can be used to limit the rate of requests to a server. It is useful for rate limiting requests to a server, for example to prevent a server from being overwhelmed by too many requests or using rate-limited APIs like the GitHub API, Spotify API, etc.

Installation

npm install request-rate-clock

Usage

import RateClock from "request-rate-clock";

const clock = RateClock.create(5, 1000); // Allow 5 requests per second

(async () => {
  for (let i = 0; i < 1000; i++) {
    await clock.acquire();
    console.log("Request", i + 1);
  }
})().catch(console.error);

API

RateClock.create(rate: number, interval: number): RateClock

Keywords

FAQs

Package last updated on 11 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc