Package Exports
- wait-utils
Readme
wait-utils
A modern toolkit for delay, timeout, and polling utilities in JavaScript and TypeScript.
Features
Rich error handling
AbortError
for signal-triggered cancellationTimeoutError
for when an operation exceeds a given timeout
Versatile polling with
poll()
- Supports
initialDelay
, dynamicdelay
, andafterPoll
hooks - Full support for
AbortSignal
for clean cancellation
- Supports
Async-friendly scheduling utilities
setTimeoutAsync
andsetIntervalAsync
for timed operations
Flexible delay helpers:
timeout()
— rejects after a delay unless the signal triggers abortwait()
— resolves after the delay or rejects if cancelledwaitUntil()
— continues until a givenperformance.now()
timestamp, unless cancelled
Designed TypeScript-first, zero runtime dependencies, fully tree‑shakeable
Documentation
See the API reference docs for full documentation.
Installation
NPM:
npm install wait-utils
PNPM:
pnpm install wait-utils
Yarn:
yarn add wait-utils
JSR:
jsr add @rojas/wait-utils
License
Sponsor
If you find this useful, consider sponsoring on GitHub.