PageRenderTime 27ms CodeModel.GetById 18ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 1ms

/node_modules/lodash/intersection.js

https://bitbucket.org/coleman333/smartsite
JavaScript | 30 lines | 11 code | 2 blank | 17 comment | 1 complexity | 2361892ec320ebb56bf1578b857f01b0 MD5 | raw file
 1var arrayMap = require('./_arrayMap'),
 2    baseIntersection = require('./_baseIntersection'),
 3    baseRest = require('./_baseRest'),
 4    castArrayLikeObject = require('./_castArrayLikeObject');
 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/7.0/#sec-samevaluezero)
 9 * for equality comparisons. The order and references of result values are
10 * determined by the first array.
11 *
12 * @static
13 * @memberOf _
14 * @since 0.1.0
15 * @category Array
16 * @param {...Array} [arrays] The arrays to inspect.
17 * @returns {Array} Returns the new array of intersecting values.
18 * @example
19 *
20 * _.intersection([2, 1], [2, 3]);
21 * // => [2]
22 */
23var intersection = baseRest(function(arrays) {
24  var mapped = arrayMap(arrays, castArrayLikeObject);
25  return (mapped.length && mapped[0] === arrays[0])
26    ? baseIntersection(mapped)
27    : [];
28});
29
30module.exports = intersection;