packages/solid/src/Debounce.ts

Summary

Maintainability
A
0 mins
Test Coverage
export class Debounce {
  #timeout?: number;

  run(fn: Function, ms: number): void {
    this.#clear();
    this.#timeout = setTimeout(fn, ms);
  }

  #clear() {
    if (this.#timeout !== undefined) {
      clearTimeout(this.#timeout);
    }
  }
}