-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
we should not plan the same task twice (#3244)
* we should not plan the same task twice * fix : fix build errors
- Loading branch information
Showing
4 changed files
with
54 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* A dynamic function that removes duplicates from an array of items. | ||
* | ||
* @param {any[]} items - The items to check against. | ||
* | ||
* @returns {any[]} - The array of items without duplicates. | ||
*/ | ||
|
||
export const removeDuplicateItems = <TItem extends { id: string }>(items?: TItem[]): TItem[] => { | ||
const seenIds = new Set<string>(); | ||
|
||
return items | ||
? items.filter((item) => { | ||
if (seenIds.has(item.id)) { | ||
return false; | ||
} else { | ||
seenIds.add(item.id); | ||
return true; | ||
} | ||
}) | ||
: []; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters