(isEquivalent: (self: A, that: A) => boolean)
| 3238 | * @since 2.0.0 |
| 3239 | */ |
| 3240 | export 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 |
no test coverage detected