You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
506 B
18 lines
506 B
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;
|
|
|