MCPcopy Create free account
hub / github.com/Effect-TS/effect / intersectionWith

Function intersectionWith

packages/effect/src/Array.ts:3240–3252  ·  view source on GitHub ↗
(isEquivalent: (self: A, that: A) => boolean)

Source from the content-addressed store, hash-verified

3238 * @since 2.0.0
3239 */
3240export const intersectionWith = <A>(isEquivalent: (self: A, that: A) => boolean): {
3241 (that: Iterable<A>): (self: Iterable<A>) => Array<A>
3242 (self: Iterable<A>, that: Iterable<A>): Array<A>
3243} => {
3244 const has = containsWith(isEquivalent)
3245 return dual(
3246 2,
3247 (self: Iterable<A>, that: Iterable<A>): Array<A> => {
3248 const thatArray = fromIterable(that)
3249 return fromIterable(self).filter((a) => has(thatArray, a))
3250 }
3251 )
3252}
3253
3254/**
3255 * Computes the intersection of two arrays using `Equal.equivalence()`. Order is

Callers 1

Array.test.tsFile · 0.85

Calls 4

filterMethod · 0.80
containsWithFunction · 0.70
fromIterableFunction · 0.70
hasFunction · 0.70

Tested by

no test coverage detected