/requestanimationframe-timer

setTimeout and setInterval by using requestAnimationFrame

Primary LanguageTypeScriptMIT LicenseMIT

requestanimationframe-timer

setTimeout and setInterval by using requestAnimationFrame

Install

npm install --save-dev requestanimationframe-timer

Usage

import { setInterval, setTimeout, clearInterval, clearTimeout } from 'requestanimationframe-timer';

const id_1 = setTimeout((a) => console.log(a), 1000, '1000 ms timeout');
const id_2 = setInterval((a) => console.log(a), 2000, '2000 ms interval');
setTimeout(() => {
  clearTimeout(id_1);
  clearInterval(id_2);
}, 10000);

Maintainers


Chua Kang Ming