CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes45downloads
unionWith.js35 linesDownload Raw Back to lodash
1var baseFlatten = require('./_baseFlatten'),2    baseRest = require('./_baseRest'),3    baseUniq = require('./_baseUniq'),4    isArrayLikeObject = require('./isArrayLikeObject'),5    last = require('./last');6 7/**8 * This method is like `_.union` except that it accepts `comparator` which9 * is invoked to compare elements of `arrays`. Result values are chosen from10 * the first array in which the value occurs. The comparator is invoked11 * with two arguments: (arrVal, othVal).12 *13 * @static14 * @memberOf _15 * @since 4.0.016 * @category Array17 * @param {...Array} [arrays] The arrays to inspect.18 * @param {Function} [comparator] The comparator invoked per element.19 * @returns {Array} Returns the new array of combined values.20 * @example21 *22 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];23 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];24 *25 * _.unionWith(objects, others, _.isEqual);26 * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]27 */28var unionWith = baseRest(function(arrays) {29  var comparator = last(arrays);30  comparator = typeof comparator == 'function' ? comparator : undefined;31  return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator);32});33 34module.exports = unionWith;35 
basant307/AI_Governance_Project · CoolFace