mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 14:37:49 +00:00
31 lines
1.0 KiB
JavaScript
31 lines
1.0 KiB
JavaScript
import baseDifference from './.internal/baseDifference.js'
|
|
import baseFlatten from './.internal/baseFlatten.js'
|
|
import isArrayLikeObject from './isArrayLikeObject.js'
|
|
|
|
/**
|
|
* Creates an array of `array` values not included in the other given arrays
|
|
* using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
|
* for equality comparisons. The order and references of result values are
|
|
* determined by the first array.
|
|
*
|
|
* **Note:** Unlike `pullAll`, this method returns a new array.
|
|
*
|
|
* @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.
|
|
* @see union, unionBy, unionWith, without, xor, xorBy, xorWith,
|
|
* @example
|
|
*
|
|
* difference([2, 1], [2, 3])
|
|
* // => [1]
|
|
*/
|
|
function difference(array, ...values) {
|
|
return isArrayLikeObject(array)
|
|
? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
|
|
: []
|
|
}
|
|
|
|
export default difference
|