Skip to content

Commit

Permalink
fix: improve the type of parameter fn
Browse files Browse the repository at this point in the history
  • Loading branch information
cszhjh committed Oct 30, 2024
1 parent 88daff6 commit 6f50bf7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { isArray } from './general'

export function NOOP() {}

export function debounce(fn: any, delay = 0) {
export function debounce(fn: (...args: any[]) => any, delay = 0) {
let timer: any

return function (this: unknown, ...args: any[]) {
Expand All @@ -16,11 +16,11 @@ export function debounce(fn: any, delay = 0) {
}
}

export function throttle(fn: any, delay = 200): () => void {
export function throttle(fn: (...args: any[]) => any, delay = 200) {
let timer: any
let start = 0

return function loop(this: unknown, ...args) {
return function loop(this: unknown, ...args: any[]) {
const now = performance.now()
const elapsed = now - start

Expand Down

0 comments on commit 6f50bf7

Please sign in to comment.