Skip to content

Commit

Permalink
Add typings for throttled and debounce (#8689)
Browse files Browse the repository at this point in the history
* Add typings for throttled and debounce
* Review feedback
* args for fn too
* one more
  • Loading branch information
kurkle committed Mar 21, 2021
1 parent 992cdec commit d79b5a3
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions types/helpers/helpers.extras.d.ts
Expand Up @@ -4,3 +4,20 @@ export function fontString(pixelSize: number, fontStyle: string, fontFamily: str
* Request animation polyfill
*/
export function requestAnimFrame(cb: () => void): void;

/**
* Throttles calling `fn` once per animation frame
* Latest argments are used on the actual call
* @param {function} fn
* @param {*} thisArg
* @param {function} [updateFn]
*/
export function throttled(fn: (...args: any[]) => void, thisArg: any, updateFn?: (...args: any[]) => any[]): (...args: any[]) => void;

/**
* Debounces calling `fn` for `delay` ms
* @param {function} fn - Function to call. No arguments are passed.
* @param {number} delay - Delay in ms. 0 = immediate invocation.
* @returns {function}
*/
export function debounce(fn: () => void, delay: number): () => number;

0 comments on commit d79b5a3

Please sign in to comment.