1.0.2 • Published 3 years ago

wait-for-any v1.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

wait-for-any

Wait until the condition is met. Used to detect dynamically injected variables, such as window.ethereum

Install

npm install wait-for-any

Example

Wait until ethereum injection

import waitFor from 'wait-for-any'
const ethereum = await waitFor(() => window.ethereum)
console.log(ethereum === window.ethereum) // true

Browser

<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 true
  • options
    • timeout: number - maximum detection time, default 5000 ms
    • step: number - interval between each detect, default 500 ms
1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago