Skip to content

Commit 9b9d161

Browse files
committed
Replace every and some with includes
1 parent 57c01f6 commit 9b9d161

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/db/db.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const NonUniqueFields = [
3333
Source.TheMovieDBSeason,
3434
Source.TheTVDB,
3535
Source.TheTVDBSeason,
36-
]
36+
] as (keyof Relation)[]
3737

3838
export type Relation = {
3939
[Source.AniDB]?: number

src/update.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ const handleBadValues = <T extends string | number | undefined>(
6767

6868
// Removes duplicate source-id pairs from the list, except for thetvdb and themoviedb ids
6969
export const removeDuplicates = (entries: Relation[]): Relation[] => {
70-
const sources = (Object.values(Source) as SourceValue[]).filter((source) =>
71-
NonUniqueFields.every((field) => field !== source),
70+
const sources = (Object.values(Source) as SourceValue[]).filter(
71+
(source) => !NonUniqueFields.includes(source),
7272
)
7373
const existing = new Map<SourceValue, Set<unknown>>(sources.map((name) => [name, new Set()]))
7474

@@ -78,9 +78,7 @@ export const removeDuplicates = (entries: Relation[]): Relation[] => {
7878

7979
// Ignore nulls
8080
if (id == null) continue
81-
// Ignore sources with one-to-many relations
82-
// eslint-disable-next-line unicorn/prefer-includes
83-
if (NonUniqueFields.some((field) => field === source)) continue
81+
if (NonUniqueFields.includes(source)) continue
8482

8583
if (existing.get(source)!.has(id)) return false
8684

0 commit comments

Comments
 (0)