MCPcopy Create free account
hub / github.com/effect-app/libs / uniq

Function uniq

packages/effect-app/src/Chunk.ts:42–53  ·  view source on GitHub ↗
(E: Equivalence<A>)

Source from the content-addressed store, hash-verified

40 * Remove duplicates from an array, keeping the first occurrence of an element.
41 */
42export function uniq<A>(E: Equivalence<A>) {
43 return (self: Chunk.Chunk<A>): Chunk.Chunk<A> => {
44 let out = Chunk.fromIterable([] as A[])
45 for (let i = 0; i < self.length; i++) {
46 const a = Chunk.getUnsafe(self, i)
47 if (!elem(E, a)(out)) {
48 out = Chunk.append(out, a)
49 }
50 }
51 return self.length === out.length ? self : out
52 }
53}
54
55/**
56 * Test if a value is a member of an array. Takes a `Equivalence<A>` as a single

Callers

nothing calls this directly

Calls 2

getUnsafeMethod · 0.80
elemFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…