Web3JS Online
Viem Online
Webhooks, Alerts, and a simple API.
The rejectIfTimeout function is a utility method provided by the web3.utils module that enforces a timeout on a promise, so that it can be rejected if it takes too long to complete. The function takes two parameters: timeout and error.
The function takes in two parameters:
The rejectIfTimeout function returns an array containing two elements:
Here's an example of how the rejectIfTimeout function can be used:
In this example, the rejectIfTimeout function is called with a timeout of 100 milliseconds and an error message of "time out". The function returns an array containing the timeout ID and a Promise that will be rejected with the error message if the timeout is reached. The Promise is then resolved with the value "hello" after 5 seconds, and the timeout is cleared using the clearTimeout function.