Skip to content

Commit

Permalink
fix Chunk uniq
Browse files Browse the repository at this point in the history
  • Loading branch information
sledorze authored and mikearnaldi committed Apr 4, 2022
1 parent fde9c1f commit c8cb091
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ export function uniq_<A>(as: Chunk.Chunk<A>, E: Equal<A>): Chunk.Chunk<A> {
const len = as.length
let i = 0
for (; i < len; i++) {
const a = as[i]!
const a = Chunk.unsafeGet_(as, i)
if (!elem_(r, E, a)) {
r = Chunk.append_(r, a)
}
Expand Down
11 changes: 11 additions & 0 deletions packages/core/test/chunk.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { pipe } from "@effect-ts/core/Function"
import { Chunk, Equal } from "@effect-ts/core/index.js"

it("should uniq", () => {
const res = pipe(
Chunk.from(["a", "b", "a", "c", "c"]),
Chunk.uniq(Equal.string),
Chunk.toArray
)
expect(res).toEqual(["a", "b", "c"])
})

0 comments on commit c8cb091

Please sign in to comment.