1 | function debounce(func, wait, immediate) {
|
2 | var timeout;
|
3 | return function () {
|
4 | var context = this, args = arguments;
|
5 | var later = function () {
|
6 | timeout = null;
|
7 | if (!immediate) {
|
8 | func.apply(context, args);
|
9 | }
|
10 | };
|
11 | var callNow = immediate && !timeout;
|
12 | clearTimeout(timeout);
|
13 | timeout = setTimeout(later, wait);
|
14 | if (callNow) {
|
15 | func.apply(context, args);
|
16 | }
|
17 | };
|
18 | }
|
19 | export default debounce;
|
20 | //# sourceMappingURL=debounce.js.map |
\ | No newline at end of file |