# aliyun-light-clock

> 定时器

Latest version **0.1.5** (published 2022-11-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install aliyun-light-clock
pnpm add aliyun-light-clock
yarn add aliyun-light-clock
bun add aliyun-light-clock
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.5 |
| Published | 2022-11-15 |
| First published | 2022-11-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 9.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | 慈铁 |
| Maintainers | light5647 |

## Links

- npm: https://www.npmjs.com/package/aliyun-light-clock
- npm.io page: https://npm.io/package/aliyun-light-clock

## Recent versions

- 0.1.5 (latest) — 2022-11-15

## README

### 介绍
- 一个使用 requestAnimationFrame 实现setTimeout、setInterval的定时器
- 支持设置定时器循环次数

### 使用方式

```
import {
  setTimeout,
  setInterval,
  clearTimeout,
  clearInterval,
  clock,
  clearClock,
} from '@ali/light-clock';

// Date.now() - creatTime > 60, 执行函数
// 使用 requestAnimationFrame判断
setTimeout(() => {
  console.log(Date.now());
}, 60);

// Date.now() - triggerTime > 60, 执行函数
// 使用 requestAnimationFrame判断
setInterval(() => {
  console.log(Date.now());
}, 60);

// Date.now() - triggerTime > 60, 执行函数，总共执行10次
// 使用 requestAnimationFrame判断

clock(() => {
  console.log(Date.now());
}, 60, 10);

```

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