Skip to content

intersectionBy() function

iterable1 に含まれる iterable2 のすべての要素の Iterable/AsyncIterable(すなわち重複なし)を返します。重複は、提供された fiterable2 に適用して返された値に従って判定されます。

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}

Open Source Code

Released under the Apache-2.0 License.