Skip to content

Instantly share code, notes, and snippets.

@the-glima
Created November 27, 2020 01:54
Show Gist options
  • Select an option

  • Save the-glima/edc1f6559224c9a169a9a4502cf5bb62 to your computer and use it in GitHub Desktop.

Select an option

Save the-glima/edc1f6559224c9a169a9a4502cf5bb62 to your computer and use it in GitHub Desktop.

Revisions

  1. the-glima created this gist Nov 27, 2020.
    11 changes: 11 additions & 0 deletions debounce.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    const debounce = (callback: Function, delay: number) => {
    let timeout: any;

    return (...args: any) => {
    clearTimeout(timeout)
    timeout = setTimeout(() => {
    timeout = null
    callback(...args)
    }, delay)
    }
    }