throttled-request is a Node.js module designed to apply rate-limiting to outgoing HTTP requests by wrapping the now-deprecated `request` library. It provides functionality to configure request throttling based on a fixed rate (e.g., N requests within M milliseconds) or a dynamic delay determined by a provided function. The package is currently at version 0.1.1, indicating an early development stage and a lack of active maintenance. Its release cadence is effectively inactive, as its last update was long ago, and its core dependency, `request`, has been officially deprecated and archived. This module's primary differentiator was its simple integration with the `request` API, making it easy for users of that library to add throttling. However, its strong reliance on an unmaintained dependency makes it unsuitable for modern applications, which should seek alternatives built on actively maintained HTTP clients.
npm install throttled-requestVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to set up `throttled-request`, configure a rate limit of 2 requests per second, listen for the 'request' event, and then make 10 throttled HTTP GET requests to a public URL.
Migrate away from `throttled-request` and its `request` dependency. Choose a modern, actively maintained HTTP client like `node-fetch`, `axios`, or the built-in `http`/`https` modules, and then integrate a separate, maintained throttling library or implement throttling directly.
Always use the main `throttledRequest(options, callback)` or `throttledRequest(options).pipe(...)` syntax for all HTTP requests. Specify the HTTP method within the `options` object (e.g., `{ method: 'POST', url: '...' }`).Given the package's age and low version, it is strongly recommended to use actively maintained alternatives for request throttling in modern Node.js environments to ensure stability, security, and compatibility.
Ensure you `require('request')` separately and then pass that instance to `throttled-request` to initialize it: `var request = require('request'); var throttledRequest = require('throttled-request')(request);`Use the main `throttledRequest(options, callback)` signature for all HTTP requests, specifying the method in the `options` object (e.g., `throttledRequest({ method: 'GET', url: '...' }, callback);`).While this error highlights the underlying problem, the ultimate solution for `throttled-request` is to migrate away from this package entirely due to its dependency on deprecated software. Consider modern HTTP clients and throttling solutions.