{"version":3,"file":"throttle.cjs","names":[],"sources":["../../src/utils/throttle.ts"],"sourcesContent":["/** throttle wraps a function so it can only be called once, and then a time window must pass before it can be called again\n * any subsequent calls before the time window has passed will be ignored.\n *\n * NOTE: if the wrapped function makes use of \"this\", it must be properly bind from the caller, as this wrapper will not bind it.\n * For this, we suggest you always pass functions declared as fat arrow functions, as they have their \"this\" lexically defined.\n * */\nexport const throttle = <F extends (...args: Parameters<F>) => ReturnType<F>>(\n  func: F,\n  timeout = 1000,\n) => {\n  let isWaiting = false;\n  return (...args: Parameters<F>) => {\n    if (isWaiting) {\n      return;\n    }\n    func(...args);\n    setTimeout(() => {\n      isWaiting = false;\n    }, timeout);\n    isWaiting = true;\n  };\n};\n"],"mappings":";;;;;;;;AAMA,MAAa,YACX,MACA,UAAU,QACP;CACH,IAAI,YAAY;CAChB,QAAQ,GAAG,SAAwB;EACjC,IAAI,WACF;EAEF,KAAK,GAAG,IAAI;EACZ,iBAAiB;GACf,YAAY;EACd,GAAG,OAAO;EACV,YAAY;CACd;AACF"}