parent
2544794c5d
commit
62f8cff980
1 changed files with 18 additions and 0 deletions
@ -0,0 +1,18 @@ |
|||||||
|
import { debounce as baseDebounce } from 'lodash'; |
||||||
|
|
||||||
|
/* eslint-disable @typescript-eslint/no-explicit-any */ |
||||||
|
|
||||||
|
type BaseDebounce<Fn extends (...args: any) => any> = typeof baseDebounce<Fn>; |
||||||
|
|
||||||
|
const debounce = <Fn extends (...args: any) => any>( |
||||||
|
fn: Fn, |
||||||
|
options: { |
||||||
|
wait?: Parameters<BaseDebounce<Fn>>[1]; |
||||||
|
} & Parameters<BaseDebounce<Fn>>[2] = {}, |
||||||
|
): ReturnType<BaseDebounce<Fn>> => { |
||||||
|
const { wait = 500, ...rest } = options; |
||||||
|
|
||||||
|
return baseDebounce<Fn>(fn, wait, rest); |
||||||
|
}; |
||||||
|
|
||||||
|
export default debounce; |
Loading…
Reference in new issue