Skip to content

Instantly share code, notes, and snippets.

@ZatsuneNoMokou
ZatsuneNoMokou / debounce.js
Last active September 10, 2017 09:28 — forked from beshur/debounce.js
javascript debounce
/**
* Debounce creates a FUNCTION that when invoked, delays invoking fn for wait milliseconds since
* the last time it is called.
*
* @param {number} fn - function to call
* @param {number} wait - duration in milliseconds
* @param {number} maxWait - max duration in milliseconds before calling {@param fn}
* @retun {function} a function that will wait {@param wait} milliseconds since it's last called to invoke {@param fn}.
*/
function debounce(fn, wait, maxWait=null) {