a zip code crypto-currency system good for red ONLY

debouncer.js 573B

1234567891011121314151617181920212223242526
  1. export class TimeoutDebouncer {
  2. constructor(wait) {
  3. this.wait = wait;
  4. this.timer = null;
  5. }
  6. debounce(callback) {
  7. this.callback = callback;
  8. this.schedule();
  9. }
  10. schedule() {
  11. this.cancel();
  12. if (this.wait <= 0) {
  13. this.callback();
  14. }
  15. else {
  16. this.timer = setTimeout(this.callback, this.wait);
  17. }
  18. }
  19. cancel() {
  20. if (this.timer) {
  21. clearTimeout(this.timer);
  22. this.timer = null;
  23. }
  24. }
  25. }
  26. //# sourceMappingURL=debouncer.js.map