e97efddb7c9c05a2c804022670eaef623b9909d9
[yaffs-website] / node_modules / grunt-legacy-util / node_modules / lodash / intersection.js
1 var arrayMap = require('./_arrayMap'),
2     baseIntersection = require('./_baseIntersection'),
3     rest = require('./rest'),
4     toArrayLikeObject = require('./_toArrayLikeObject');
5
6 /**
7  * Creates an array of unique values that are included in all given arrays
8  * using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
9  * for equality comparisons.
10  *
11  * @static
12  * @memberOf _
13  * @category Array
14  * @param {...Array} [arrays] The arrays to inspect.
15  * @returns {Array} Returns the new array of shared values.
16  * @example
17  *
18  * _.intersection([2, 1], [4, 2], [1, 2]);
19  * // => [2]
20  */
21 var intersection = rest(function(arrays) {
22   var mapped = arrayMap(arrays, toArrayLikeObject);
23   return (mapped.length && mapped[0] === arrays[0])
24     ? baseIntersection(mapped)
25     : [];
26 });
27
28 module.exports = intersection;