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

Function intersectionWith

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

Source from the content-addressed store, hash-verified

3397 * @since 2.0.0
3398 */
3399export const intersectionWith = <A>(isEquivalent: (self: A, that: A) => boolean): {
3400 (that: Iterable<A>): (self: Iterable<A>) => Array<A>
3401 (self: Iterable<A>, that: Iterable<A>): Array<A>
3402} => {
3403 const has = containsWith(isEquivalent)
3404 return dual(
3405 2,
3406 (self: Iterable<A>, that: Iterable<A>): Array<A> => {
3407 const thatArray = fromIterable(that)
3408 return fromIterable(self).filter((a) => has(thatArray, a))
3409 }
3410 )
3411}
3412
3413/**
3414 * Computes the intersection of two arrays using `Equal.asEquivalence()`. Order is

Callers 1

Array.test.tsFile · 0.85

Calls 4

containsWithFunction · 0.70
fromIterableFunction · 0.70
hasFunction · 0.70
filterMethod · 0.45

Tested by

no test coverage detected