10LOC

#file-watching

Node.jsintermediate

A debounced fs.watch file watcher, no chokidar

import { watch } from "node:fs";

export const watchDebounced = (path: string, onChange: (eventType: string) => void, waitMs = 200) => {
  let timer: NodeJS.Timeout | undefined;

fs.watch fires multiple times for a single logical change; debouncing it with a plain setTimeout gets you chokidar's core behavior for free.