mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 15:57:48 +00:00
41 lines
1.4 KiB
JavaScript
41 lines
1.4 KiB
JavaScript
/**
|
|
* lodash 3.1.0 (Custom Build) <https://lodash.com/>
|
|
* Build: `lodash modern modularize exports="npm" -o ./`
|
|
* Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
|
|
* Based on Underscore.js 1.8.2 <http://underscorejs.org/LICENSE>
|
|
* Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
* Available under MIT license <https://lodash.com/license>
|
|
*/
|
|
var baseDifference = require('lodash._basedifference'),
|
|
baseFlatten = require('lodash._baseflatten'),
|
|
isArguments = require('lodash.isarguments'),
|
|
isArray = require('lodash.isarray'),
|
|
restParam = require('lodash.restparam');
|
|
|
|
/**
|
|
* Creates an array excluding all values of the provided arrays using
|
|
* `SameValueZero` for equality comparisons.
|
|
*
|
|
* **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
|
|
* comparisons are like strict equality comparisons, e.g. `===`, except that
|
|
* `NaN` matches `NaN`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Array
|
|
* @param {Array} array The array to inspect.
|
|
* @param {...Array} [values] The arrays of values to exclude.
|
|
* @returns {Array} Returns the new array of filtered values.
|
|
* @example
|
|
*
|
|
* _.difference([1, 2, 3], [4, 2]);
|
|
* // => [1, 3]
|
|
*/
|
|
var difference = restParam(function(array, values) {
|
|
return (isArray(array) || isArguments(array))
|
|
? baseDifference(array, baseFlatten(values, false, true))
|
|
: [];
|
|
});
|
|
|
|
module.exports = difference;
|