Given this array, containing javascript objects (json):
Each object has a b
property, and a u
property,
(each contains additional properties I am not concerned with for this exercise).
[
{ "b": "A", "u": "F", ... },
{ "b": "M", "u": "T", ... },
{ "b": "A", "u": "F", ... },
{ "b": "M", "u": "T", ... },
{ "b": "M", "u": "T", ... },
{ "b": "X", "u": "Y", ... },
{ "b": "X", "u": "G", ... },
]
I would like to use ramda to find a set of all the duplicates. The result should look something like this.
[
{ "b": "A", "u":"F" },
{ "b": "M", "u":"T" }
]
These two entries have duplicates they are repeated 2 and 3 times in the original list respectively.
edit
I have found a solution using underscore, that keeps the original array elements, and splits them perfectly into singles and duplicates. I prefer ramda.js, and underscore doesn't just give a set of duplicates - as per the question, so I am leaving the question open until someone can answer using ramda. I am moving on with underscore until the question is answered.
I have a repl that finds the unique values... as a start...
This seems overcomplicated and unlikely to be performant, but one options would be this:
Perhaps this version is easier to understand, but it takes an extra iteration through the data:
repl here