https://github.com/andrepolischuk/wait-for-target
Wait for a target is ready
https://github.com/andrepolischuk/wait-for-target
ready target wait
Last synced: 2 months ago
JSON representation
Wait for a target is ready
- Host: GitHub
- URL: https://github.com/andrepolischuk/wait-for-target
- Owner: andrepolischuk
- License: mit
- Created: 2017-04-20T12:52:18.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2020-03-03T10:00:38.000Z (about 5 years ago)
- Last Synced: 2025-01-04T01:54:04.157Z (4 months ago)
- Topics: ready, target, wait
- Language: JavaScript
- Size: 11.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# wait-for-target [![Build Status][travis-image]][travis-url]
> Wait for a target is ready
## Install
```sh
npm install --save wait-for-target
```## Usage
```js
import waitForTarget from 'wait-for-target'async function push (...args) {
const analytics = await waitForTarget(() => window.ga)analytics('send', 'event', ...args)
}push('ready')
```## API
### waitForTarget(getTarget[, timeout])
Return a promise that resolves to target when ready.
#### getTarget
Type: `function`
Function returns a target for resolve.
#### timeout
Type: `number`
Default: `Infinity`Waiting timeout.
## License
MIT
[travis-url]: https://travis-ci.org/andrepolischuk/wait-for-target
[travis-image]: https://travis-ci.org/andrepolischuk/wait-for-target.svg?branch=master