JAVASCRIPT   6

difference.js

Guest on 11th June 2021 03:43:49 AM

  1. var baseDifference = require('../internal/baseDifference'),
  2.     baseFlatten = require('../internal/baseFlatten'),
  3.     isArrayLike = require('../internal/isArrayLike'),
  4.     isObjectLike = require('../internal/isObjectLike'),
  5.     restParam = require('../function/restParam');
  6.  
  7. /**
  8.  * Creates an array of unique `array` values not included in the other
  9.  * provided arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
  10.  * for equality comparisons.
  11.  *
  12.  * @static
  13.  * @memberOf _
  14.  * @category Array
  15.  * @param {Array} array The array to inspect.
  16.  * @param {...Array} [values] The arrays of values to exclude.
  17.  * @returns {Array} Returns the new array of filtered values.
  18.  * @example
  19.  *
  20.  * _.difference([1, 2, 3], [4, 2]);
  21.  * // => [1, 3]
  22.  */
  23. var difference = restParam(function(array, values) {
  24.   return (isObjectLike(array) && isArrayLike(array))
  25.     ? baseDifference(array, baseFlatten(values, false, true))
  26.     : [];
  27. });
  28.  
  29. module.exports = difference;

Raw Paste


Login or Register to edit or fork this paste. It's free.