- Remove `noopFalse` from `@revenge-mod/utils/callback` - Do not return result from unpatch/undo/unsub functions - `onSettingsModulesLoaded` from `@revenge-mod/discord/modules/settings` now calls the callback immediately if settings modules are already loaded instead of throwing
15 lines
388 B
TypeScript
15 lines
388 B
TypeScript
export function debounce<F extends (...args: any[]) => any>(
|
|
func: F,
|
|
timeout: number,
|
|
) {
|
|
let timer: Parameters<typeof clearTimeout>[0]
|
|
return (...args: Parameters<F>) =>
|
|
new Promise(rs => {
|
|
clearTimeout(timer)
|
|
timer = setTimeout(() => {
|
|
rs(func(...args))
|
|
}, timeout)
|
|
})
|
|
}
|
|
|
|
export const noop = () => {}
|