UNPKG

bbo

Version:

bbo is a utility library of zero dependencies for javascript.

13 lines (10 loc) 285 B
'use strict'; /** * Returns a list of elements that exist in both arrays, * after applying the provided function to each array element of both. */ function intersectBy(a, b, fn) { var s = new Set(b.map(fn)); return a.filter(x => s.has(fn(x))); } module.exports = intersectBy;