277b836e6ebc7163b6881469e33436054f6fb5ca
[platform/framework/web/crosswalk-tizen.git] /
1 var baseDifference = require('../internal/baseDifference'),
2     baseFlatten = require('../internal/baseFlatten'),
3     isArguments = require('../lang/isArguments'),
4     isArray = require('../lang/isArray'),
5     restParam = require('../function/restParam');
6
7 /**
8  * Creates an array excluding all values of the provided arrays using
9  * `SameValueZero` for equality comparisons.
10  *
11  * **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
12  * comparisons are like strict equality comparisons, e.g. `===`, except that
13  * `NaN` matches `NaN`.
14  *
15  * @static
16  * @memberOf _
17  * @category Array
18  * @param {Array} array The array to inspect.
19  * @param {...Array} [values] The arrays of values to exclude.
20  * @returns {Array} Returns the new array of filtered values.
21  * @example
22  *
23  * _.difference([1, 2, 3], [4, 2]);
24  * // => [1, 3]
25  */
26 var difference = restParam(function(array, values) {
27   return (isArray(array) || isArguments(array))
28     ? baseDifference(array, baseFlatten(values, false, true))
29     : [];
30 });
31
32 module.exports = difference;