# timer

定时器工具函数

## Functions

### sleep

睡眠函数

```ts
function sleep(timer: number): Promise<void>
```

**Example**

```ts
await sleep(1000) // 等待 1 秒
```

### raf

监听下一动画帧（Promise）

```ts
function raf(): Promise<void>
```

**Example**

```ts
raf().then(() => {
  console.log('执行下一帧')
})
```

### doubleRaf

监听双帧动画帧（Promise）

```ts
function doubleRaf(): Promise<void>
```

**Example**

```ts
doubleRaf().then(() => {
  console.log('执行双帧后')
})
```

### clearTimer

清除定时器

```ts
function clearTimer(timerId: number | undefined): void
```

## Usage

```ts
import { sleep, raf, doubleRaf } from '@allkit/shared'

// 睡眠
await sleep(100)

// 下一帧
raf().then(() => {
  console.log('执行下一帧')
})

// 双帧
doubleRaf().then(() => {
  console.log('执行双帧后')
})
```
