UNPKG

lenye_base

Version:

基础方法

13 lines (10 loc) 288 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;