export type TaskIdentity = {
  id: number;
};

export function dedupeTasksById<T extends TaskIdentity>(tasks: T[]): T[] {
  const seen = new Set<number>();
  const unique: T[] = [];

  tasks.forEach((task) => {
    if (seen.has(task.id)) {
      return;
    }
    seen.add(task.id);
    unique.push(task);
  });

  return unique;
}
