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

Function reraf

index.js:241–273  ·  view source on GitHub ↗
(limit)

Source from the content-addressed store, hash-verified

239 var cAF = compat ? cancelAnimationFrame : clearTimeout;
240 var rAF = compat ? requestAnimationFrame : setTimeout;
241 function reraf(limit) {
242 var force, timer, callback, self, args;
243 reset();
244 return function reschedule(_callback, _self, _args) {
245 callback = _callback;
246 self = _self;
247 args = _args;
248 if (!timer) timer = rAF(invoke);
249 if (--force < 0) stop(true);
250 return stop;
251 };
252
253 function invoke() {
254 reset();
255 callback.apply(self, args || []);
256 }
257
258 function reset() {
259 force = limit || Infinity;
260 timer = compat ? 0 : null;
261 }
262
263 function stop(flush) {
264 var didStop = !!timer;
265
266 if (didStop) {
267 cAF(timer);
268 if (flush) invoke();
269 }
270
271 return didStop;
272 }
273 }
274
275 var umap = (function (_) {
276 return {

Callers 2

useReducerFunction · 0.70
createEffectFunction · 0.70

Calls 2

resetFunction · 0.70
stopFunction · 0.70

Tested by

no test coverage detected