w3reality / fps-run-js

A JavaScript utility class that enables fps-throttled function execution.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

fps-run-js

npm MIT licensed CI

A JavaScript utility class that enables fps-throttled function execution. Internally, requestAnimationFrame() is arranged to execute a user-provided function at a specified fps. The code is based on this Stack Overflow discussion and its related JSFiddle demo. Node.js support was added using setImmediate() instead of requestAnimationFrame().

The module is compiled as a UMD (Universal Module Definition) module. So it can be consumed by script-tags, AMD loading (require.js), and Node.js.

Usage

npm install fps-run-js, load fps-run.js and in code:

fr = new FpsRun(); // create a runner
fr.start(f, 5); // execute function f() at 5 fps
//...
fr.stop(); // stop execution

Live Demos 🔥

Build


$ npm i
$ npm run build

About

A JavaScript utility class that enables fps-throttled function execution.

License:MIT License


Languages

Language:JavaScript 100.0%