Skip to content

throttle

Create a throttle function that calls fn at most once every delay milliseconds.

Usage

ts
import { throttle } from 'rattail'

const throttledFn = throttle(() => {
  // do something, it will be called at most 1 time per second
}, 1000)

window.addEventListener('resize', throttledFn)

Arguments

ArgTypeDefaults
fnFunction
delaynumber200

Return

Type
Function