1.0.2 • Published 4 years ago
wait-for-any v1.0.2
wait-for-any
Wait until the condition is met. Used to detect dynamically injected variables, such as window.ethereum
Install
npm install wait-for-anyExample
Wait until ethereum injection
import waitFor from 'wait-for-any'
const ethereum = await waitFor(() => window.ethereum)
console.log(ethereum === window.ethereum) // trueBrowser
<script src="dist/index.js">
<script>
window.waitFor()
</script>Parameter
waitFor(condition, [options])
condition: function - if the return value is not null, the condition is trueoptionstimeout: number - maximum detection time, default 5000 msstep: number - interval between each detect, default 500 ms