7 lines
216 B
JavaScript
7 lines
216 B
JavaScript
function intersectionBy(firstArr, secondArr, mapper) {
|
|
const mappedSecondSet = new Set(secondArr.map(mapper));
|
|
return firstArr.filter(item => mappedSecondSet.has(mapper(item)));
|
|
}
|
|
|
|
export { intersectionBy };
|