时间累加器无论调用累加器的速率是多少,都以恒定速率调用函数。例子:这会导致render函数每5毫秒调用一次,无论requestAnimationFrame以何种速率调用accum


var timeAccumulator = require('time-accumulator');

var accum = timeAccumulator(5.0);

var render = function(elapsed) { /* ... */ };

window.requestAnimationFrame(function(elapsed) { accum(elapsed, render); });

安装用法npm install time-accumulator

执照:麻省理工学院