MCPcopy Create free account
hub / github.com/compiler-explorer/compiler-explorer / intersection

Function intersection

shared/common-utils.ts:40–43  ·  view source on GitHub ↗
(a: V[], b: V[])

Source from the content-addressed store, hash-verified

38}
39
40export function intersection<V>(a: V[], b: V[]): V[] {
41 const B = new Set(b);
42 return [...a].filter(item => B.has(item));
43}
44
45// arr.filter(x => x !== null) returns a (T | null)[] even though it is a T[]
46// Apparently the idiomatic solution is arr.filter((x): x is T => x !== null), but this is shorter (and the type

Callers 1

fillCompilersMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected