---
title: "sleep"
description: "Return a promise that resolves after the given number of milliseconds, letting you pause an async flow with a simple await expression."
canonical_url: "https://core.mhaibaraai.cn/en/docs/utilities/async/sleep"
---
# sleep

> Return a promise that resolves after the given number of milliseconds, letting you pause an async flow with a simple await expression.

## Usage

`sleep` returns a promise that resolves after the specified number of milliseconds, pausing execution of an async function.

```ts
import { sleep } from '@movk/core'

// Wait 1 second before continuing
await sleep(1000)
console.log('Executed after 1 second')

// Using inside an async function
async function delayedOperation() {
  console.log('Start')
  await sleep(500)
  console.log('Executed after 500ms')
}
```

## API

### `sleep(ms)`

Return a promise that resolves after the given number of milliseconds.

### Parameters

**ms** (`number`) *required*: The delay duration in milliseconds.

### Returns

**returns** (`Promise<void>`): A promise that resolves after the delay.

## Changelog

See commit history for [src/utilities/async/sleep.ts](https://github.com/mhaibaraai/movk-core/commits/main/src/utilities/async/sleep.ts).

---

- [GitHub](https://github.com/mhaibaraai/movk-core/blob/main/src/utilities/async/sleep.ts)


## Sitemap

See the full [sitemap](https://core.mhaibaraai.cn/sitemap.md) for all pages.
