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

Function debounce

src/helpers/helpers.extras.ts:50–61  ·  view source on GitHub ↗
(fn: (...args: TArgs) => void, delay: number)

Source from the content-addressed store, hash-verified

48 * Debounces calling `fn` for `delay` ms
49 */
50export function debounce<TArgs extends Array<any>>(fn: (...args: TArgs) => void, delay: number) {
51 let timeout;
52 return function(...args: TArgs) {
53 if (delay) {
54 clearTimeout(timeout);
55 timeout = setTimeout(fn, delay, args);
56 } else {
57 fn.apply(this, args);
58 }
59 return delay;
60 };
61}
62
63/**
64 * Converts 'start' to 'left', 'end' to 'right' and others to 'center'

Callers 1

constructorMethod · 0.85

Calls 1

applyMethod · 0.80

Tested by

no test coverage detected