intersectionBy
intersectionBy() function
Returns Iterable/AsyncIterable(i.e no duplicate) of all elements in the iterable2
contained in the iterable1
. Duplication is determined according to the value returned by applying the supplied f
to iterable2
.
declare function intersectionBy<A, B = unknown>(f: (a: A) => B, iterable1: Iterable<A>, iterable2: Iterable<A>): IterableIterator<A>;
declare function intersectionBy<A, B = unknown>(f: (a: A) => B, iterable1: AsyncIterable<A>, iterable2: Iterable<A>): AsyncIterableIterator<A>;
declare function intersectionBy<A, B = unknown>(f: (a: A) => B, iterable1: Iterable<A>, iterable2: AsyncIterable<A>): AsyncIterableIterator<A>;
declare function intersectionBy<A, B = unknown>(f: (a: A) => B, iterable1: AsyncIterable<A>, iterable2: AsyncIterable<A>): AsyncIterableIterator<A>;
Example
const iter = intersectionBy(a => a.x, [{ x: 1 }, { x: 4 }], [{ x: 1 }, { x: 2 }, { x: 3 }])
iter.next(); // {value: {x: 1, done: false}
iter.next(); // {value: undefined, done: true}