'use strict';

const { GLib } = imports.gi;

/* exported setTimeout */
function setTimeout(func, millis) {
  return GLib.timeout_add(GLib.PRIORITY_DEFAULT, millis, () => {
    func();
    // Don't repeat
    return false;
  });
}

/* exported clearTimeout */
function clearTimeout(id) {
  return GLib.Source.remove(id);
}

/* exported setInterval */
function setInterval(func, millis) {
  return GLib.timeout_add(GLib.PRIORITY_DEFAULT, millis, () => {
    func();
    // Repeat
    return true;
  });
}

/* exported clearInterval */
function clearInterval(id) {
  return GLib.Source.remove(id);
}

/* exported debounce */
function debounce(func, millis) {
  let timer = null;
  return function debounceInner(...args) {
    const context = this;
    if (timer !== null) {
      clearTimeout(timer);
    }
    timer = setTimeout(() => {
      func.apply(context, args);
      timer = null;
    }, millis);
  };
}

@@ -57,855 +57,263 @@
  set
-Timeout */%0Afunction setTimeout(func, millis) %7B%0A  return GLib.timeout_add(GLib.PRIORITY_DEFAULT, millis, () =%3E %7B%0A    func();%0A    // Don't repeat%0A    return false;%0A  %7D);%0A%7D%0A%0A/* exported clearTimeout */%0Afunction clearTimeout(id) %7B%0A  return GLib.Source.remove(id);%0A%7D%0A%0A/* exported setInterval */%0Afunction setInterval(func, millis) %7B%0A  return GLib.timeout_add(GLib.PRIORITY_DEFAULT, millis, () =%3E %7B%0A    func();%0A    // Repeat%0A    return true;%0A  %7D);%0A%7D%0A%0A/* exported clearInterval */%0Afunction clearInterval(id) %7B%0A  return GLib.Source.remove(id);%0A%7D%0A%0A/* exported debounce */%0Afunction debounce(func, millis) %7B%0A  let timer = null;%0A  return function debounceInner(...args) %7B%0A    const context = this;%0A    if (timer !== null) %7B%0A      clearTimeout(timer);%0A    %7D%0A    timer = setTimeout(() =%3E %7B%0A      func.apply(context, args);%0A      timer = null;%0A    %7D, millis);%0A  %7D
+Interval */%0Afunction setInterval(func, millis) %7B%0A  return GLib.timeout_add(GLib.PRIORITY_DEFAULT, millis, () =%3E %7B%0A    func();%0A    // Repeat%0A    return true;%0A  %7D);%0A%7D%0A%0A/* exported clearInterval */%0Afunction clearInterval(id) %7B%0A  return GLib.Source.remove(id)
 ;%0A%7D%0A

Remove unused functions