HeadlinesBriefing favicon HeadlinesBriefing.com

Temporize: TypeScript Debounce & Concurrency Utilities

Hacker News •
×

Temporize is a small, strongly typed library for controlling when and how often work runs in modern TypeScript. It provides promise-aware debounce, throttle, batching, retries, concurrency limits, and React/Vue adapters with zero runtime dependencies. Every scheduled call returns a real promise for the wrapped function's actual result, with full generic inference and native promise rejection.

The library supports multiple debounce strategies including async overlap policies: "queue" (default), "drop", and "cancel-previous". Throttling options include regular throttling with leading/trailing edges, animation-frame throttling via `rafThrottle`, and promise-based rate limiting with FIFO queues. Batch processing collects multiple calls into single invocations while retry mechanisms use exponential backoff with randomized jitter.

Additional utilities include idle-period scheduling with browser API fallbacks, concurrency limiting with FIFO queues, and cooperative cancellation via `cancel()` methods and AbortSignal. The package ships as both ESM and CommonJS, with framework adapters as optional subpath exports.

Lodash compatibility is maintained while adding TypeScript-specific features. Installation is straightforward via npm, and the modular design ensures only needed functionality is loaded. React and Vue adapters are available as separate peer dependencies.