1 var arrayMap = require('./internal/arrayMap'),
2 baseIntersection = require('./internal/baseIntersection'),
3 baseIteratee = require('./internal/baseIteratee'),
4 last = require('./last'),
5 rest = require('./rest'),
6 toArrayLikeObject = require('./internal/toArrayLikeObject');
9 * This method is like `_.intersection` except that it accepts `iteratee`
10 * which is invoked for each element of each `arrays` to generate the criterion
11 * by which uniqueness is computed. The iteratee is invoked with one argument: (value).
16 * @param {...Array} [arrays] The arrays to inspect.
17 * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element.
18 * @returns {Array} Returns the new array of shared values.
21 * _.intersectionBy([2.1, 1.2], [4.3, 2.4], Math.floor);
24 * // using the `_.property` iteratee shorthand
25 * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
28 var intersectionBy = rest(function(arrays) {
29 var iteratee = last(arrays),
30 mapped = arrayMap(arrays, toArrayLikeObject);
32 if (iteratee === last(mapped)) {
37 return (mapped.length && mapped[0] === arrays[0])
38 ? baseIntersection(mapped, baseIteratee(iteratee))
42 module.exports = intersectionBy;