param delay param fn return export function throttle < T extends ( ... args : any [ ] ) => any , R extends ( ... args : Parameters < T > ) => Promise < ReturnType < T > > > ( fn , delay ) { let last = 0 ; let result ; return async function ( ... args ) { return new Promise ( ( resolve ) => { const curr = Date . now ( ) ; if ( curr - last > delay ) { result = fn ( ... args ) ; last = curr ; resolve ( result ) ; return ; } resolve ( result ) ; } ) ; } as R ; }