turbowatch
Version:
Extremely fast file change detector and task orchestrator for Node.js.
22 lines (17 loc) • 475 B
text/typescript
import { type FileChangeEvent } from './types';
export const deduplicateFileChangeEvents = (
fileChangeEvents: readonly FileChangeEvent[],
): readonly FileChangeEvent[] => {
const changedFilePaths: string[] = [];
return fileChangeEvents
.slice()
.reverse()
.filter((event) => {
if (changedFilePaths.includes(event.filename)) {
return false;
}
changedFilePaths.push(event.filename);
return true;
})
.reverse();
};