Lodash FlatMap example

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.4/lodash.js"></script>
<div id="result">

</div>

JavaScript

const arr = [{"numeroCnpjPartner":"29982505000180","nomePartner":"TEST1","cgeId":"70821","nomeFundo":"BTG PACTUAL TESOURO IPCA CURTO FI RF","error":""},{"numeroCnpjPartner":"93030897000187","nomePartner":"TEST2","cgeId":"48132","nomeFundo":"BTG PACTUAL FIX FI RF","error":""},{"numeroCnpjPartner":"01386973000173","nomePartner":"TEST3","cgeId":"11111","nomeFundo":"","error":"ERROR_002"},{"numeroCnpjPartner":"1110111011101","nomePartner":"","cgeId":"317620","nomeFundo":"BTGP ACCESS MAUA MACRO FIC FI MULT","error":"ERROR_001"},{"numeroCnpjPartner":"29982505000180","nomePartner":"TEST1","cgeId":"70821","nomeFundo":"BTG PACTUAL TESOURO IPCA CURTO FI RF","error":""}]

const c1 = {"numeroCnpjPartner":"29982505000180","nomePartner":"TEST1","cgeId":"70821","nomeFundo":"BTG PACTUAL TESOURO IPCA CURTO FI RF","error":""}

uniqueArray = arr.filter((item) => {
	const found = arr.some( (el) => el.numeroCnpjPartner === item.numeroCnpjPartner && el.cgeId === item.cgeId)
  console.log(found)
	return item
})

console.log(uniqueArray)
/* 

console.log( arr.indexOf(c1) )

 */
 
 
 
/* function checkAndAdd(name) {
  const id = arr.length + 1;
  const found = arr.some(function (el) {
    return el.username === name;
  });
  if (!found) { arr.push({ id: id, username: name }); }
}
 */
/* const found = arr.some( (el) => el.numeroCnpjPartner === c1.numeroCnpjPartner && el.cgeId === c1.cgeId)

console.log(found)
 */



/* 
const grantedPermissions = (yield role.getPermissions()).filter((item) =>
	(item.name).includes('ACCOUNT_SEGMENT')
).map(item => (item.name).split('ACCOUNT_SEGMENT_').pop()) */