MCPcopy Create free account
hub / github.com/WebReflection/neverland / reraf

Function reraf

test/neverland.js:320–352  ·  view source on GitHub ↗
(limit)

Source from the content-addressed store, hash-verified

318 var cAF = compat ? cancelAnimationFrame : clearTimeout;
319 var rAF = compat ? requestAnimationFrame : setTimeout;
320 function reraf(limit) {
321 var force, timer, callback, self, args;
322 reset();
323 return function reschedule(_callback, _self, _args) {
324 callback = _callback;
325 self = _self;
326 args = _args;
327 if (!timer) timer = rAF(invoke);
328 if (--force < 0) stop(true);
329 return stop;
330 };
331
332 function invoke() {
333 reset();
334 callback.apply(self, args || []);
335 }
336
337 function reset() {
338 force = limit || Infinity;
339 timer = compat ? 0 : null;
340 }
341
342 function stop(flush) {
343 var didStop = !!timer;
344
345 if (didStop) {
346 cAF(timer);
347 if (flush) invoke();
348 }
349
350 return didStop;
351 }
352 }
353
354 /*! (c) Andrea Giammarchi - ISC */
355 var updates = new WeakMap();

Callers 2

useStateFunction · 0.70
createEffectFunction · 0.70

Calls 2

resetFunction · 0.70
stopFunction · 0.70

Tested by

no test coverage detected