intersectionBy() function
返回 iterable2 中包含在 iterable1 中的所有元素的 Iterable/AsyncIterable(即无重复)。重复项根据将提供的 f 应用于 iterable2 返回的值来确定。
Signature:
typescript
declare function intersectionBy<A, B = unknown>(
f: (a: A) => B,
iterable1: Iterable<A>,
iterable2: Iterable<A>,
): IterableIterator<A>;Example
ts
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}