Skip to content

Instantly share code, notes, and snippets.

@amkurian
Created February 21, 2020 06:42
Show Gist options
  • Save amkurian/995e689b4a14ff15a4b59cd11c76f18d to your computer and use it in GitHub Desktop.
Save amkurian/995e689b4a14ff15a4b59cd11c76f18d to your computer and use it in GitHub Desktop.
const intersectionBy = (a, b, fn) => {
const s = new Set(b.map(fn));
return a.filter(x => s.has(fn(x)));
};
intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor); // [2.1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment