bbo
Version:
bbo is a utility library of zero dependencies for javascript.
15 lines (11 loc) • 503 B
JavaScript
;
var _rollupPluginBabelHelpers = require('./internal/_rollupPluginBabelHelpers.js');
/**
* Returns every element that exists in any of the two arrays once,
* after applying the provided function to each array element of both.
*/
var unionBy = (a, b, fn) => {
var s = new Set(a.map(fn));
return Array.from(new Set([].concat(_rollupPluginBabelHelpers._toConsumableArray(a), _rollupPluginBabelHelpers._toConsumableArray(b.filter(x => !s.has(fn(x)))))));
};
module.exports = unionBy;