Registry /
testing / simple-rate-limited-queue
Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
RateLimitedQueue
✓ import { RateLimitedQueue } from 'simple-rate-limited-queue'
✗ const RateLimitedQueue = require('simple-rate-limited-queue')
ESM-only package; no CommonJS support.
withRetry
✓ import { withRetry } from 'simple-rate-limited-queue'
✗ import withRetry from 'simple-rate-limited-queue'
Named export, not default.
RateLimitedQueue type (TypeScript)
✓ import { RateLimitedQueue } from 'simple-rate-limited-queue//types'
✗ import { RateLimitedQueue } from 'simple-rate-limited-queue'
Types are bundled, no extra path needed; this entry is just to clarify that types are available.
Creates a rate-limited queue, schedules an async fetch operation, and shows retry logic on failure.
import { RateLimitedQueue, withRetry } from 'simple-rate-limited-queue';
const queue = new RateLimitedQueue({
maxPerInterval: 5,
maxInProgress: 2,
intervalLength: 1000
});
async function fetchUser(id: number): Promise<any> {
const response = await queue.schedule(() => fetch(`https://api.example.com/users/${id}`));
return response.json();
}
// Usage
fetchUser(1).then(console.log).catch(console.error);
// With retry
const fetchWithRetry = withRetry(
(id: number) => fetch(`https://api.example.com/users/${id}`).then(r => r.json()),
(err: any, count: number) => count < 3 ? 1000 : undefined
);
queue.schedule(() => fetchWithRetry(2)).then(console.log);
Errors
Common errors & fixes
ERR_REQUIRE_ESM: Must use import to load ES Module: /path/to/node_modules/simple-rate-limited-queue/index.js
Attempting to require() the ESM-only package in a CommonJS module.
fixUse import syntax or convert your project to ESM.
TypeError: queue.schedule is not a function
Importing default instead of named export.
fixUse import { RateLimitedQueue } from 'simple-rate-limited-queue'. Error: The queue has been terminated
Trying to schedule an operation after calling terminate() without reset().
fixCall queue.reset() before scheduling new operations after termination.
Audit
Dependencies
No dependency data recorded yet.