aliyun-light-clock

0.1.5 • Public • Published

介绍

  • 一个使用 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);

/aliyun-light-clock/

    Package Sidebar

    Install

    npm i aliyun-light-clock

    Weekly Downloads

    1

    Version

    0.1.5

    License

    MIT

    Unpacked Size

    10.1 kB

    Total Files

    7

    Last publish

    Collaborators

    • light5647