Files
lodash/difference.js
John-David Dalton b7e3b3febd Bump to v4.9.0.
2016-04-08 01:32:35 -07:00

31 lines
963 B
JavaScript

import baseDifference from './_baseDifference';
import baseFlatten from './_baseFlatten';
import isArrayLikeObject from './isArrayLikeObject';
import rest from './rest';
/**
* Creates an array of unique `array` values not included in the other given
* arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
* for equality comparisons. The order of result values is determined by the
* order they occur in the first array.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Array
* @param {Array} array The array to inspect.
* @param {...Array} [values] The values to exclude.
* @returns {Array} Returns the new array of filtered values.
* @example
*
* _.difference([3, 2, 1], [4, 2]);
* // => [3, 1]
*/
var difference = rest(function(array, values) {
return isArrayLikeObject(array)
? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
: [];
});
export default difference;