A promise-based utility for delaying execution with support for abort signals, random delays, and unlimited timeout lengths.
Delay is a JavaScript library that provides promise-based utilities for delaying execution in asynchronous code. It solves the problem of managing timed operations in promise chains with features like abort signals, random delays, and support for unlimited timeout lengths that native `setTimeout` doesn't offer.
JavaScript developers working with async/await patterns who need reliable timing utilities for testing, web scraping, animations, or any scenario requiring controlled delays in promise-based workflows.
Developers choose Delay over native timing functions because it provides a cleaner promise-based API, supports modern features like AbortSignal for cancellation, offers unlimited delay lengths, and includes utilities like random delays that are particularly useful for testing and avoiding predictable patterns.
Delay a promise a specified amount of time
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Returns promises that seamlessly work with async/await syntax, simplifying asynchronous code flow as shown in the basic usage example.
Supports standard AbortSignal for canceling delays, providing better control over asynchronous operations compared to manual clearTimeout, with clear error handling.
Includes rangeDelay for generating delays between min and max values, explicitly designed for testing and web scraping to avoid predictable patterns.
Allows delays longer than the native 24.8-day setTimeout limit, enabling long-term timing without workarounds.
The README notes that Node.js users can use native timers/promises, making Delay unnecessary unless browser support or extra features like random delays are required.
Focuses solely on delays without built-in methods for intervals, forcing developers to implement or use additional libraries for repeated timing tasks.
Adds an external package where simple use cases might be handled with native setTimeout, introducing extra complexity and potential performance overhead in high-frequency scenarios.