import type { DebouncedFunc } from "./debounce" ; import { debounce } from "./debounce" ; import { isObject } from "./isObject" ; type ThrottleOptions = { leading ? : boolean ; trailing ? : boolean ; } ; param { Function } func param { number } wait param options param { boolean } options . leading param { boolean } options . trailing returns { Function } example export function throttle < T extends ( ... args : any ) => any > ( func , wait ? , options ? ) { if ( typeof func !== "function" ) { throw new TypeError ( "Expected a function" ) ; } let leading = true ; let trailing = true ; if ( isObject ( options ) ) { leading = "leading" in options ? ! ! options . leading : leading ; trailing = "trailing" in options ? ! ! options . trailing : trailing ; } return debounce ( func , wait , { leading , trailing , maxWait : wait , } ) ; }