How to use the uniqWith function from lodash
Find comprehensive JavaScript lodash.uniqWith code examples handpicked from public code repositorys.
GitHub: firewalla/firewalla
470 471 472 473 474 475 476 477 478 479
const nonLinkLocal = item.ip6_subnets .filter(_.isString) .map(n => new Address6(n)) .filter(a => !a.isLinkLocal()) // multiple IPs in same subnet might be assigned this.sysinfo[r].subnetAddress6 = _.uniqWith(nonLinkLocal, (a,b) => a.startAddress().canonicalForm() == b.startAddress().canonicalForm() && a.subnetMask == b.subnetMask ) for (const subnet6 of this.sysinfo[r].subnetAddress6) { cidr6Trie.add(`${subnet6.correctForm()}/${subnet6.subnetMask}`, r);
117
456
48
+ 7 other calls in file
413 414 415 416 417 418 419 420 421 422
module.exports.union = _.union; module.exports.unionBy = _.unionBy; module.exports.unionWith = _.unionWith; module.exports.uniq = _.uniq; module.exports.uniqBy = _.uniqBy; module.exports.uniqWith = _.uniqWith; module.exports.uniqueId = _.uniqueId; module.exports.unset = _.unset; module.exports.unsplat = _.unsplat; module.exports.unsplatl = _.unsplatl;
19
122
0
+ 92 other calls in file
GitHub: mdmarufsarker/lodash
165 166 167 168 169 170 171 172 173 174 175 176 177
console.log(uniq); // => [2, 1] const uniqBy = _.uniqBy([2.1, 1.2, 2.3], Math.floor); console.log(uniqBy); // => [2.1, 1.2] const uniqWith = _.uniqWith([2.1, 1.2, 2.3], (a, b) => Math.floor(a) === Math.floor(b)); console.log(uniqWith); // => [2.1, 1.2] const unzip = _.unzip([['a', 1, true], ['b', 2, false]]); console.log(unzip); // => [['a', 'b'], [1, 2], [true, false]]
0
4
0
+ 15 other calls in file
GitHub: kingsdigitallab/kdl
315 316 317 318 319 320 321 322 323 324
const researchersOrganisationAgents = await this.getOrCreateAgents( "organisation", researchersOrganisations ); const funderNames = _.uniqWith( projects .flatMap((project) => project.funder) .filter((name) => name.length > 0) .map((name) => ({ name: name })),
0
0
5
+ 54 other calls in file
142 143 144 145 146 147 148 149 150 151
} return principles; }; // levelsDisplay() { // return _.reverse( // _.uniqWith( // this.levels.map((l) => { // return { name: l.attributes.name, code: l.attributes.code }; // }), // _.isEqual
0
0
2
+ 119 other calls in file
399 400 401 402 403 404 405 406 407
if (makeUnique) { //make the elements of that array unique propsToAggregate.forEach(function (prop) { let itemArray = _.get(uniqueObjects[key], prop); itemArray = _.uniqWith(itemArray, _.isEqual); _.set(uniqueObjects[key], prop, itemArray); }); }
0
0
3
+ 51 other calls in file
GitHub: shei99/github-actions
189 190 191 192 193 194 195 196 197 198 199 200
}) } } } errorList = uniqWith(errorList, isEqual) return errorList }
0
0
1
+ 2 other calls in file
GitHub: saumyatalwani/blogBack
462 463 464 465 466 467 468 469 470 471
}); return acc; }, []); const models = _.uniqWith(appModels.concat(pluginsModels, componentModels), _.isEqual); definition.associations.push({ alias: key, targetUid: '*',
0
0
1
429 430 431 432 433 434 435 436 437 438 439
res = getPathItems(document,1); break; default: break; } res = _.uniqWith(res,_.isEqual); return res; } module.exports = { findType }
0
0
1
GitHub: bhangun/keris
45 46 47 48 49 50 51 52 53 54
* uniqProperties from array * @param {*} properties * @returns Unique array object */ function uniqProperties(properties) { const arr = _.uniqWith(properties, _.isEqual) return _.filter(arr, (a) => { if(a != null) return a.length > 0 return false
0
0
0
GitHub: Hupeng7/es6demo
476 477 478 479 480 481 482 483 484 485 486 487
console.log('uniqBy2--->', uniqBy2); //uniqBy2---> [ { x: 1 }, { x: 2 } ] //_.uniqWith(array,[comparator]) let uniqWithArr = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }]; let uniqWith1 = _.uniqWith(uniqWithArr, _.isEqual); console.log('uniqWith1--->', uniqWith1); //uniqWith1---> [ { x: 1, y: 2 }, { x: 2, y: 1 } ] //_.unzip(array)
0
0
0
397 398 399 400 401 402 403 404 405 406
}); } } // Array of facts of this category // Remove duplicates using lodash's _.uniqWith() then sort by the alphabetical order of 'prettyName' collatedCancerFactObj.facts = _.sortBy(_.uniqWith(factsArr, _.isEqual), ['name']); // Add collatedFactObj to allCollatedFacts only when the facts array is not empty after all the above filtering // E.g., treatment facts can be an empty array if the treatements are OtherTherapeuticProcedure and OtherMedication
0
0
0
+ 3 other calls in file
lodash.get is the most popular function in lodash (7670 examples)