Skip to content

Commit

Permalink
Remove continue label
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelmairegger committed May 24, 2024
1 parent fd77907 commit 6ef3d9c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 18 deletions.
14 changes: 8 additions & 6 deletions src/async/_private/distinctAsync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@ export const distinctAsync = <TSource>(

async function* iterator() {
const distinctElements: TSource[] = []
outerLoop:
for await (const item of source) {
let found = false
for (const distinctElement of distinctElements) {
const found = await comparer(distinctElement, item)
if (found) {
continue outerLoop
if (await comparer(distinctElement, item)) {
found = true
break
}
}

distinctElements.push(item)
yield item
if (!found) {
distinctElements.push(item)
yield item
}
}
}

Expand Down
12 changes: 7 additions & 5 deletions src/parallel/_private/distinctAsync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@ export const distinctAsync = <TSource>(
comparer: IAsyncEqualityComparer<TSource>): IParallelEnumerable<TSource> => {
const generator = async () => {
const distinctElements: TSource[] = []
outerLoop:
for (const item of await source.toArray()) {
let found = false
for (const distinctElement of distinctElements) {
const found = await comparer(distinctElement, item)
if (found) {
continue outerLoop
if (await comparer(distinctElement, item)) {
found = true
break
}
}

distinctElements.push(item)
if (!found) {
distinctElements.push(item)
}
}

return distinctElements
Expand Down
16 changes: 9 additions & 7 deletions src/sync/_private/distinctAsync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@ export const distinctAsync = <TSource>(

async function* iterator() {
const distinctElements: TSource[] = []
outerLoop:
for (const item of source) {
for await (const item of source) {
let found = false
for (const distinctElement of distinctElements) {
const found = await comparer(distinctElement, item)
if (found) {
continue outerLoop
if (await comparer(distinctElement, item)) {
found = true
break
}
}

distinctElements.push(item)
yield item
if (!found) {
distinctElements.push(item)
yield item
}
}
}

Expand Down

0 comments on commit 6ef3d9c

Please sign in to comment.