Registry / devops / leaky-bucket-queue

leaky-bucket-queue

JSON →
library0.0.2jsnpmunverified

An RxJS-based leaky bucket rate limiter implementing burstable throttling with a queue. Version 0.0.2 provides a simple, type-safe queue that allows bursts of traffic up to a configurable burst size within a sliding period. Ideal for smoothing API calls while maintaining responsiveness. Compared to simpler throttle/debounce approaches, leaky bucket permits short bursts without stuttering. Currently in early development with limited API surface. No significant release cadence established.

npm install leaky-bucket-queue
INSTALL
IMPORT
SIG · LEAKY-BUCKET-QUEUE
L
leaky-bucket-queue
devopsjavascriptv0.0.2
harness data pending
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.

LeakyBucketQueue
import { LeakyBucketQueue } from 'leaky-bucket-queue'
const LeakyBucketQueue = require('leaky-bucket-queue').LeakyBucketQueue
ESM-only package; CommonJS require() requires .default for default exports but LeakyBucketQueue is named.
ILeakyBucketQueueOptions
import { ILeakyBucketQueueOptions } from 'leaky-bucket-queue'
import ILeakyBucketQueueOptions from 'leaky-bucket-queue'
Type is exported as named; default import not available.
LeakyBucketQueue type
import type { LeakyBucketQueue } from 'leaky-bucket-queue'
TypeScript users should use type-only imports when only using for type annotations.

Creates a LeakyBucketQueue, subscribes to items, and enqueues three string items.

import { LeakyBucketQueue } from 'leaky-bucket-queue'; const queue = new LeakyBucketQueue<string>({ burstSize: 5, period: 100 }); queue.consume().subscribe({ next: (item: string) => console.log('Processing:', item), error: (err: any) => console.error('Error:', err), }); queue.enqueue('item1'); queue.enqueue('item2'); queue.enqueue('item3');
Debug
Known issues
breakingThe consume() method returns an Observable that emits items as they are allowed through the rate limiter. If you forget to subscribe, items will not be consumed.
fix
Always call .subscribe() on the observable returned by consume() to start processing.
affects: >=0.0.1
gotchaEnqueueing items after the consumer subscription may lead to apparent delays if burstSize is reached; items are queued internally until the next period.
fix
Increase burstSize or period to allow higher throughput.
affects: >=0.0.1
gotchaThe package does not export a default export. Attempting import LeakyBucketQueue from 'leaky-bucket-queue' (without braces) results in undefined.
fix
Use named import: import { LeakyBucketQueue } from 'leaky-bucket-queue'
affects: >=0.0.1
deprecatedNo known deprecations yet.
affects: >=0.0.1
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'subscribe')
Called .subscribe() on undefined because import used default import instead of named import.
fix
Ensure import: import { LeakyBucketQueue } from 'leaky-bucket-queue'
Error: LeakyBucketQueue is not a constructor
Trying to instantiate without new or using wrong import that doesn't include the class.
fix
Use new LeakyBucketQueue({ burstSize: 5, period: 100 }) after correct named import.
rxjs: Unhandled error in observable sequence. If you would like to handle errors, use catchError or subscribe with error callback.
No error handler in subscribe when consumer emits an error (e.g., queue processing failure).
fix
Add error callback: queue.consume().subscribe({ next: ..., error: ... })
Upgrade
Version history
0.0.2latest on npm
Audit
Dependencies
rxjsrequiredCore dependency for Observable-based consumption and queue management.
Agent activity
2 hits · last 30 days
node
2
Resources
leaky-bucket-queue — npm install leaky-bucket-queue · libregistry