carbon-components-svelte
Version:
Svelte implementation of the Carbon Design System
11 lines (9 loc) • 323 B
TypeScript
export type RafThrottled<Fn extends (...args: unknown[]) => void> = ((
...args: Parameters<Fn>
) => void) & {
cancel: () => void;
};
/** Run `fn` at most once per frame; same-frame calls keep the latest arguments. */
export function rafThrottle<Fn extends (...args: unknown[]) => void>(
fn: Fn,
): RafThrottled<Fn>;