1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.default = debounce;
|
7 |
|
8 |
|
9 |
|
10 | function debounce(func) {
|
11 | var wait = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 166;
|
12 | var timeout;
|
13 |
|
14 | function debounced() {
|
15 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
16 | args[_key] = arguments[_key];
|
17 | }
|
18 |
|
19 |
|
20 | var that = this;
|
21 |
|
22 | var later = function later() {
|
23 | func.apply(that, args);
|
24 | };
|
25 |
|
26 | clearTimeout(timeout);
|
27 | timeout = setTimeout(later, wait);
|
28 | }
|
29 |
|
30 | debounced.clear = function () {
|
31 | clearTimeout(timeout);
|
32 | };
|
33 |
|
34 | return debounced;
|
35 | } |
\ | No newline at end of file |