
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
A TypeScript library for implementing customizable polling mechanisms with adjustable timeouts and intervals.
The Wait library provides a convenient way to implement polling mechanisms with customizable timeouts and intervals in TypeScript.
You can install the Wait library via npm:
npm install ts-wait
import { Wait } from 'ts-wait';
// Basic usage
await new Wait<Document>(() => client.documents.getDocument(id))
.pollingEvery(1000)
.withTimeout(20000)
.until(document => document.status === 'COMPLETED')
// With maximum attempts limit
await new Wait<Document>(() => client.documents.getDocument(id))
.pollingEvery(1000)
.withMaxAttempts(10) // Stop after 10 polling attempts
.until(document => document.status === 'COMPLETED')
// With exponential backoff
await new Wait<Document>(() => client.documents.getDocument(id))
.pollingEvery(1000) // Initial interval
.withExponentialBackoff(2, 10000) // Multiply by 2 each time, max 10 seconds
.withTimeout(60000)
.until(document => document.status === 'COMPLETED')
// Combining features
await new Wait<Document>(() => client.documents.getDocument(id))
.pollingEvery(500)
.withMaxAttempts(15)
.withExponentialBackoff(1.5) // Gradually increase with 1.5x multiplier
.withTimeout(30000)
.until(document => document.status === 'COMPLETED')
Wait<T>
A class that represents the Wait library.
Constructor
new Wait(call: () => Promise<T>): Creates a new Wait instance with the provided asynchronous function.
withTimeout(timeout: number): Wait<T>: Sets the timeout for waiting in milliseconds (default: 30000)
pollingEvery(interval: number): Wait<T>: Sets the polling interval in milliseconds (default: 1000).
withMessage(message: string): Wait<T>: Sets a custom error message.
withMaxAttempts(maxAttempts: number): Wait<T>: Sets the maximum number of polling attempts. The polling will stop when either the timeout is reached or the maximum number of attempts is exceeded, whichever comes first.
withExponentialBackoff(multiplier: number = 2, maxInterval?: number): Wait<T>: Enables exponential backoff for the polling interval. The interval will be multiplied by the specified multiplier after each attempt. Optionally, you can set a maximum interval to cap the growth.
multiplier: The factor by which to multiply the interval (default: 2)maxInterval: Optional maximum interval in milliseconds to prevent unbounded growthasync until(condition: (it: T) => boolean): Promise<T>: Waits until the provided condition function returns true or the timeout/max attempts is reached. Returns the result when the condition is met.
Contributions are welcome! Feel free to submit issues or pull requests.
This library is licensed under the MIT License. See the LICENSE file for details.
FAQs
A TypeScript library for implementing customizable polling mechanisms with adjustable timeouts and intervals.
The npm package ts-wait receives a total of 472 weekly downloads. As such, ts-wait popularity was classified as not popular.
We found that ts-wait demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.