mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-31 15:27:50 +00:00
48 lines
1.5 KiB
JavaScript
48 lines
1.5 KiB
JavaScript
/**
|
|
* lodash 3.0.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.7.0 <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');
|
|
|
|
/**
|
|
* Creates an array excluding all values of the provided arrays using
|
|
* `SameValueZero` for equality comparisons.
|
|
*
|
|
* **Note:** `SameValueZero` comparisons are like strict equality comparisons,
|
|
* e.g. `===`, except that `NaN` matches `NaN`. See the
|
|
* [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
|
|
* for more details.
|
|
*
|
|
* @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]
|
|
*/
|
|
function difference() {
|
|
var index = -1,
|
|
length = arguments.length;
|
|
|
|
while (++index < length) {
|
|
var value = arguments[index];
|
|
if (isArray(value) || isArguments(value)) {
|
|
break;
|
|
}
|
|
}
|
|
return baseDifference(value, baseFlatten(arguments, false, true, ++index));
|
|
}
|
|
|
|
module.exports = difference;
|