1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | function debounce(func, wait, immediate) {
|
4 | var timeout;
|
5 | return function () {
|
6 | var context = this, args = arguments;
|
7 | var later = function () {
|
8 | timeout = null;
|
9 | if (!immediate) {
|
10 | func.apply(context, args);
|
11 | }
|
12 | };
|
13 | var callNow = immediate && !timeout;
|
14 | clearTimeout(timeout);
|
15 | timeout = setTimeout(later, wait);
|
16 | if (callNow) {
|
17 | func.apply(context, args);
|
18 | }
|
19 | };
|
20 | }
|
21 | exports.default = debounce;
|
22 |
|
\ | No newline at end of file |