UNPKG
matt-tools
Version:
latest (1.0.1)
1.0.1
个人工具
matt-tools
/
src
/
debounce
/
index.js
15 lines
(13 loc)
•
257 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
export
const
debounce
= (
dn, delay
) => {
var
delay = delay ||
500
;
this
.
timer
;
return
() =>
{
if
(
this
.
timer
) {
clearTimeout
(
this
.
timer
); }
this
.
timer
=
setTimeout
(
() =>
{
this
.
timer
=
null
; fn.
apply
(
this
,
arguments
); }, delay); }; };