mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 15:57:48 +00:00
Bump to v3.0.0.
This commit is contained in:
39
array/difference.js
Normal file
39
array/difference.js
Normal file
@@ -0,0 +1,39 @@
|
||||
import baseDifference from '../internal/baseDifference';
|
||||
import baseFlatten from '../internal/baseFlatten';
|
||||
import isArguments from '../lang/isArguments';
|
||||
import isArray from '../lang/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], [5, 2, 10]);
|
||||
* // => [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));
|
||||
}
|
||||
|
||||
export default difference;
|
||||
Reference in New Issue
Block a user