Security update to Drupal 8.4.6
[yaffs-website] / web / core / misc / debounce.js
1 /**
2 * DO NOT EDIT THIS FILE.
3 * See the following change record for more information,
4 * https://www.drupal.org/node/2815083
5 * @preserve
6 **/
7
8 Drupal.debounce = function (func, wait, immediate) {
9   var timeout = void 0;
10   var result = void 0;
11   return function () {
12     var context = this;
13     var args = arguments;
14     var later = function later() {
15       timeout = null;
16       if (!immediate) {
17         result = func.apply(context, args);
18       }
19     };
20     var callNow = immediate && !timeout;
21     clearTimeout(timeout);
22     timeout = setTimeout(later, wait);
23     if (callNow) {
24       result = func.apply(context, args);
25     }
26     return result;
27   };
28 };