-
Notifications
You must be signed in to change notification settings - Fork 0
/
05-debounce.js
18 lines (18 loc) · 775 Bytes
/
05-debounce.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/**
* Creates a debounced function that delays invoking `func` until after `wait`
* milliseconds have elapsed since the last time the debounced function was
* invoked, or until the next browser frame is drawn.
*
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
* for details over the differences between `debounce` and `throttle`.
*
* @category Function
* @param {Function} func The function to debounce.
* @param {number} The number of milliseconds to delay.
* @returns {Function} Returns the new debounced function.
* @example
*
* // Avoid costly calculations while the window size is in flux.
* jQuery(window).on('resize', debounce(calculateLayout, 150))
*/
export default function debounce(func, wait) {}