# wait-for-async

> Async wait for

Latest version **0.8.1** (published 2026-04-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install wait-for-async
pnpm add wait-for-async
yarn add wait-for-async
bun add wait-for-async
```

## Health

**Score 55/100 (C)** — status: active.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.8.1 |
| Published | 2026-04-22 |
| First published | 2020-05-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Maintainers | tylerlong |

## Links

- npm: https://www.npmjs.com/package/wait-for-async
- Repository: https://github.com/tylerlong/wait-for-async
- Homepage: https://github.com/tylerlong/wait-for-async#readme
- Issues: https://github.com/tylerlong/wait-for-async/issues
- npm.io page: https://npm.io/package/wait-for-async

## Recent versions

- 0.8.1 (latest) — 2026-04-22
- 0.8.0 — 2025-11-04
- 0.7.13 — 2025-02-04
- 0.7.12 — 2025-02-04
- 0.7.11 — 2025-02-04
- 0.7.10 — 2025-01-28
- 0.7.9 — 2025-01-17
- 0.7.8 — 2025-01-17
- 0.7.7 — 2025-01-17
- 0.7.6 — 2025-01-16
- 0.7.5 — 2025-01-06
- 0.7.4 — 2025-01-06
- 0.7.3 — 2025-01-06
- 0.7.2 — 2024-12-21
- 0.7.1 — 2024-12-21
- … 9 more at https://npm.io/package/wait-for-async/versions

## README

# wait-for-async

```ts
import waitFor from `wait-for-async`;

await waitFor({ interval, condition, times });
```

Wait for `condition()` to be `true`.
Its value is checked every `interval` milliseconds,
check no more than `times` intervals in total.

Whenever `condition()` becomes `true`, return `true`.
If `condition()` never becomes `true` until `times` intervals passed, return `false`.

## Parameters explained

### interval

The intervals (in milliseconds) on how often to check `condition()`'s value.
The default value is `100`.

At least 1 interval will be waited before `condition()` is checked,
even if `condition()` is `true` at the very beginning.

### condition

`condition()` is a method that returns `true` or `false`.
The default value is `() => true`.

### times

How many times in total to check `condition()`'s value before giving up.
The default value is `Infinity`.

These are the maximum times to check. Fewer times to check if `condition()`'s value becomes `true` sooner.

### return value

`true` if `condition()` becomes `true` before giving up, otherwise return `false`.

Or simply put, `condition()`'s value will be returned.

## Interesting use cases

### Wait for file downloading

Wait for the `download` to become `true` (this variable should be updated by the file downloading code).
Check the `download` value every second (the `interval`'s default value is 100ms), and give up after 60 seconds(60 checks).

### "Delay" the app for 3 seconds

```ts
await waitFor({ interval: 3000 });
```

---
_Source: https://npm.io/package/wait-for-async · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
