# base/wait (vanilla.js 0.4.0)

> https://vanillapunch.com/docs/vanilla.js/0.4.0/api/base/wait/

Asynchronous wait functions. (await seconds or frames)

Example: Wait a moment, then continue

```js
import { Wait } from "./build/vanilla.js";

const startTime = performance.now();
await Wait.seconds(0.2);
const elapsedMilliseconds = performance.now() - startTime;
console.log(elapsedMilliseconds >= 190);
```

## Functions and constants

- `async seconds(seconds)` (method, since 0.0.8): Waits asynchronously for a given time.
  - `seconds` number: Time to wait. (seconds, measured with setTimeout)
  - returns System.Promise<void>: A promise that resolves when the time has passed.
- `async nextFrame()` (method, since 0.0.9): Waits asynchronously for one frame.
  - returns System.Promise<void>: A promise that resolves on the next requestAnimationFrame. (browser only, rejected if there is no window)

  Example: Wait until the next frame

  ```js
  import { Wait } from "./build/vanilla.js";
  
  await Wait.nextFrame();
  await Wait.nextFrame();
  console.log("two frames later");
  ```

