MCPcopy
hub / github.com/chartjs/Chart.js / throttled

Function throttled

src/helpers/helpers.extras.ts:27–45  ·  view source on GitHub ↗
(
  fn: (...args: TArgs) => void,
  thisArg: any,
)

Source from the content-addressed store, hash-verified

25 * Latest arguments are used on the actual call
26 */
27export function throttled<TArgs extends Array<any>>(
28 fn: (...args: TArgs) => void,
29 thisArg: any,
30) {
31 let argsToUse = [] as TArgs;
32 let ticking = false;
33
34 return function(...args: TArgs) {
35 // Save the args for use later
36 argsToUse = args;
37 if (!ticking) {
38 ticking = true;
39 requestAnimFrame.call(window, () => {
40 ticking = false;
41 fn.apply(thisArg, argsToUse);
42 });
43 }
44 };
45}
46
47/**
48 * Debounces calling `fn` for `delay` ms

Callers 2

createResizeObserverFunction · 0.85
createProxyAndListenFunction · 0.85

Calls 1

applyMethod · 0.80

Tested by

no test coverage detected